结构定义@H_404_7@ |
CREATE table@H_404_7@ | 创建新表。 语法: sql-command::=@H_404_7@ | CREATE [TEMP | TEMPORARY] table table-name ( column-def [, column-def]* [, constraint]* )@H_404_7@ | sql-command::=@H_404_7@ | CREATE [TEMP | TEMPORARY] table [database-name.] table-name AS select-statement@H_404_7@ | column-def::=@H_404_7@ | name [type] [[CONSTRAINT name] column-constraint]*@H_404_7@ | type::=@H_404_7@ | typename | typename ( number ) | typename ( number , number )@H_404_7@ | column-constraint::=@H_404_7@ | NOT NulL [ conflict-clause ] | PRIMARY KEY [sort-order] [ conflict-clause ] | UNIQUE [ conflict-clause ] | CHECK ( expr ) [ conflict-clause ] | DEFAulT value | ColLATE collation-name@H_404_7@ | constraint::=@H_404_7@ | PRIMARY KEY ( column-List ) [ conflict-clause ] | UNIQUE ( column-List ) [ conflict-clause ] | CHECK ( expr ) [ conflict-clause ]@H_404_7@ | conflict-clause::=@H_404_7@ | ON CONFliCT conflict-algorithm@H_404_7@ | @H_404_7@ |
CREATE VIEW@H_404_7@ | 创建一个视图(虚拟表),该表以另一种方式表示一个或多个表中的数据。 语法: sql-command::=@H_404_7@ | CREATE [TEMP | TEMPORARY] VIEW [database-name.] vIEw-name AS select-statement@H_404_7@ | 例子: CREATE VIEW master_vIEw AS SELECT * FROM sqlite_master WHERE type='vIEw'; 说明: 创建一个名为master_vIEw的视图,其中包括sqlite_master这个表中的所有视图表。@H_404_7@ |
CREATE TRIGGER@H_404_7@ | 创建触发器,触发器是一种特殊的存储过程,在用户试图对指定的表执行指定的数据修改语句时自动执行。 语法: sql-statement::=@H_404_7@ | CREATE [TEMP | TEMPORARY] TRIGGER trigger-name [ BEFORE | AFTER ] database-event ON [database-name .] table-name trigger-action@H_404_7@ | sql-statement::=@H_404_7@ | CREATE [TEMP | TEMPORARY] TRIGGER trigger-name INSTEAD OF database-event ON [database-name .] vIEw-name trigger-action@H_404_7@ | database-event::=@H_404_7@ | DELETE | INSERT | UPDATE | UPDATE OF column-List@H_404_7@ | trigger-action::=@H_404_7@ | [ FOR EACH ROW | FOR EACH STATEMENT ] [ WHEN Expression ] BEGIN trigger-step ; [ trigger-step ; ]* END@H_404_7@ | trigger-step::=@H_404_7@ | update-statement | insert-statement | delete-statement | select-statement@H_404_7@ | 例子: CREATE TRIGGER update_customer_address UPDATE OF address ON customers BEGIN UPDATE orders SET address = new.address WHERE customer_name = old.name; END; 说明: 创建了一个名为update_customer_address的触发器,当用户更新customers表中的address字段时,将触发并更新orders表中的address字段为新的值。 比如执行如下一条语句: UPDATE customers SET address = '1 Main St.' WHERE name = 'Jack Jones'; 数据库将自动执行如下语句: UPDATE orders SET address = '1 Main St.' WHERE customer_name = 'Jack Jones'; @H_404_7@ |
CREATE INDEX@H_404_7@ | 为给定表或视图创建索引。 语法: sql-statement::=@H_404_7@ | CREATE [UNIQUE] INDEX index-name ON [database-name .] table-name ( column-name [, column-name]* ) [ ON CONFliCT conflict-algorithm ]@H_404_7@ | column-name::=@H_404_7@ | name [ ColLATE collation-name] [ ASC | DESC ]@H_404_7@ | 例子: CREATE INDEXIDx_email ON customers (email); 说明: 为customers表中的email创建一个名为IDx_email的字段。 @H_404_7@ |
结构删除@H_404_7@ |
DROP table@H_404_7@ | 删除表定义及该表的所有索引。 语法: sql-command::=@H_404_7@ | DROP table [database-name.] table-name@H_404_7@ | 例子: DROP table customers;@H_404_7@ |
DROP VIEW@H_404_7@ | 删除一个视图。 语法: sql-command::=@H_404_7@ | DROP VIEW vIEw-name@H_404_7@ | 例子: DROP VIEW master_vIEw; @H_404_7@ |
DROP TRIGGER@H_404_7@ | 删除一个触发器。 语法: sql-statement::=@H_404_7@ | DROP TRIGGER [database-name .] trigger-name@H_404_7@ | 例子: DROP TRIGGER update_customer_address; @H_404_7@ |
DROP INDEX@H_404_7@ | 删除一个索引。 语法: sql-command::=@H_404_7@ | DROP INDEX [database-name .] index-name@H_404_7@ | 例子: DROP INDEX IDx_email; @H_404_7@ |
数据 *** 作@H_404_7@ |
INSERT@H_404_7@ | 将新行插入到表。 语法: sql-statement::=@H_404_7@ | INSERT [OR conflict-algorithm] INTO [database-name .] table-name [(column-List)] VALUES(value-List) | INSERT [OR conflict-algorithm] INTO [database-name .] table-name [(column-List)] select-statement@H_404_7@ | @H_404_7@ |
UPDATE@H_404_7@ | 更新表中的现有数据。 语法: sql-statement::=@H_404_7@ | UPDATE [ OR conflict-algorithm ] [database-name .] table-name SET assignment [, assignment]* [WHERE expr]@H_404_7@ | assignment::=@H_404_7@ | column-name = expr@H_404_7@ | @H_404_7@ |
DELETE@H_404_7@ | 从表中删除行。 语法: sql-statement::=@H_404_7@ | DELETE FROM [database-name .] table-name [WHERE expr]@H_404_7@ | @H_404_7@ |
SELECT@H_404_7@ | 从表中检索数据。 语法: sql-statement::=@H_404_7@ | SELECT [ALL | disTINCT] result [FROM table-List] [WHERE expr] [GROUP BY expr-List] [HAVING expr] [compound-op select]* [ORDER BY sort-expr-List] [liMIT integer [( OFFSET | , ) integer]]@H_404_7@ | result::=@H_404_7@ | result-column [, result-column]*@H_404_7@ | result-column::=@H_404_7@ | * | table-name . * | expr [ [AS] string ]@H_404_7@ | table-List::=@H_404_7@ | table [join-op table join-args]*@H_404_7@ | table::=@H_404_7@ | table-name [AS alias] | ( select ) [AS alias]@H_404_7@ | join-op::=@H_404_7@ | , | [NATURAL] [left | RIGHT | FulL] [OUTER | INNER | CROSS] JOIN@H_404_7@ | join-args::=@H_404_7@ | [ON expr] [USING ( ID-List )]@H_404_7@ | sort-expr-List::=@H_404_7@ | expr [sort-order] [, expr [sort-order]]*@H_404_7@ | sort-order::=@H_404_7@ | [ ColLATE collation-name ] [ ASC | DESC ]@H_404_7@ | compound_op::=@H_404_7@ | UNION | UNION ALL | INTERSECT | EXCEPT@H_404_7@ | @H_404_7@ |
REPLACE@H_404_7@ | 类似INSERT 语法: sql-statement::=@H_404_7@ | REPLACE INTO [database-name .] table-name [( column-List )] VALUES ( value-List ) | REPLACE INTO [database-name .] table-name [( column-List )] select-statement@H_404_7@ | @H_404_7@ |
事务处理@H_404_7@ |
BEGIN TRANSACTION@H_404_7@ | 标记一个事务的起始点。 语法: sql-statement::=@H_404_7@ | BEGIN [TRANSACTION [name]]@H_404_7@ | @H_404_7@ |
END TRANSACTION@H_404_7@ | 标记一个事务的终止。 语法: sql-statement::=@H_404_7@ | END [TRANSACTION [name]]@H_404_7@ | @H_404_7@ |
COMMIT TRANSACTION@H_404_7@ | 标志一个事务的结束。 语法: sql-statement::=@H_404_7@ | COMMIT [TRANSACTION [name]]@H_404_7@ | @H_404_7@ |
RolLBACK TRANSACTION@H_404_7@ | 将事务回滚到事务的起点。 语法: sql-statement::=@H_404_7@ | RolLBACK [TRANSACTION [name]]@H_404_7@ | @H_404_7@ |
其他 *** 作@H_404_7@ |
copY@H_404_7@ | 主要用于导入大量的数据。 语法: sql-statement::=@H_404_7@ | copY [ OR conflict-algorithm ] [database-name .] table-name FROM filename [ USING DEliMITERS delim ]@H_404_7@ | 例子: copYcustomers FROM customers.csv;@H_404_7@ |
EXPLAIN@H_404_7@ | 语法: sql-statement::=@H_404_7@ | EXPLAIN sql-statement@H_404_7@ | @H_404_7@ |
PRAGMA@H_404_7@ | 语法: sql-statement::=@H_404_7@ | PRAGMA name [= value] | PRAGMA function(arg)@H_404_7@ | @H_404_7@ |
VACUUM@H_404_7@ | 语法: sql-statement::=@H_404_7@ | VACUUM [index-or-table-name]@H_404_7@ | @H_404_7@ |
ATTACH DATABASE@H_404_7@ | 附加一个数据库到当前的数据库连接。 语法: sql-statement::=@H_404_7@ | ATTACH [DATABASE] database-filename AS database-name@H_404_7@ | @H_404_7@ |
DETTACH DATABASE@H_404_7@ | 从当前的数据库分离一个使用ATTACH DATABASE附加的数据库。 语法: sql-command::=@H_404_7@ | DETACH [DATABASE] database-name@H_404_7@ | @H_404_7@ |
评论列表(0条)