个性化阅读
专注于IT技术分析

SQLite的语法

语法是一套独特的规则和准则。以下是SQLite的语法的列表。

区分大小写:

  • SQLite是不区分大小写。但是,也有一些命令,这是区分大小写的。
  • 例如:GLOB和水珠在SQLite的声明不同的含义。

注释:

  • 注释用于在SQLite的代码添加更多的可读性。
  • 注释不能嵌套。
  • 注释以两个连续的“ – ”字符。
  • 有时它也出现了“/ *”和向上延伸并包括下一个“* /”字符对。

SQLite的声明

所有SQLite的语句开始与任何类似SELECT,INSERT,UPDATE,DELETE,修改,删除等关键字的所有语句将用分号(;)结束。

SQLite的Analyze语句

句法:

ANALYZE;
or
ANALYZE database_name;
or
ANALYZE database_name.table_name;

SQLite和/或条款

句法:

SELECT column1,column2....columnN
FROM   table_name
WHERE  CONDITION-1 {AND|OR} CONDITION-2;

SQLite的ALTER TABLE语句

句法:

ALTER TABLE table_name ADD COLUMN column_def...;

SQLite的ALTER TABLE语句(重命名)

句法:

ALTER TABLE table_name RENAME TO new_table_name;

SQLite的附加数据库声明

句法:

ATTACH DATABASE 'DatabaseName' As 'Alias-Name';

SQLite的BEGIN TRANSACTION语句

句法:

BEGIN;
or
BEGIN EXCLUSIVE TRANSACTION;

SQLite的条款之间

句法:

SELECT column1,column2....columnN
FROM   table_name
WHERE  column_name BETWEEN val-1 AND val-2;
SQLite COMMIT Statement:
COMMIT;

SQLite的CREATE INDEX语句

句法:

CREATE INDEX index_name
ON table_name ( column_name COLLATE NOCASE );

SQLite的CREATE UNIQUE INDEX语句

句法:

CREATE UNIQUE INDEX index_name
ON table_name ( column1,column2,...columnN);

SQLite的CREATE TABLE语句

句法:

CREATE TABLE table_name(
   column1 datatype,column2 datatype,column3 datatype,.....
   columnN datatype,PRIMARY KEY( one or more columns ));

SQLite的CREATE TRIGGER语句

句法:

CREATE TRIGGER database_name.trigger_name 
BEFORE INSERT ON table_name FOR EACH ROW
BEGIN 
   stmt1; 
   stmt2;
   ....
END;

SQLite的CREATE VIEW语句

句法:

CREATE VIEW database_name.view_name  AS
SELECT statement....;

SQLite的创建虚拟TABLE语句

句法:

CREATE VIRTUAL TABLE database_name.table_name USING weblog( access.log );
or
CREATE VIRTUAL TABLE database_name.table_name USING fts3( );

SQLite的COMMIT TRANSACTION语句

句法:

COMMIT;

SQLite的COUNT条款

句法:

SELECT COUNT(column_name)
FROM   table_name
WHERE  CONDITION;

SQLite的DELETE语句

句法:

DELETE FROM table_name
WHERE  {CONDITION};

SQLite的分离数据库声明

句法:

DETACH DATABASE 'Alias-Name';

SQLite的DISTINCT子句

句法:

SELECT DISTINCT column1,column2....columnN
FROM   table_name;

SQLite的DROP INDEX语句

句法:

DROP INDEX database_name.index_name;

SQLite的DROP TABLE语句

句法:

DROP TABLE database_name.table_name;

SQLite的DROP VIEW声明

句法:

DROP INDEX database_name.view_name;

SQLite的DROP TRIGGER声明

句法:

DROP INDEX database_name.trigger_name;

SQLite的EXISTS子句

句法:

SELECT column1,column2....columnN
FROM   table_name
WHERE  column_name EXISTS (SELECT * FROM   table_name );

SQLite的EXPLAIN语句

句法:

EXPLAIN INSERT statement...;
or 
EXPLAIN QUERY PLAN SELECT statement...;

SQLite的GLOB条款

句法:

SELECT column1,column2....columnN
FROM   table_name
WHERE  column_name GLOB { PATTERN };

SQLite的GROUP BY子句

句法:

SELECT SUM(column_name)
FROM   table_name
WHERE  CONDITION
GROUP BY column_name;

SQLite的HAVING子句

句法:

SELECT SUM(column_name)
FROM   table_name
WHERE  CONDITION
GROUP BY column_name
HAVING (arithematic function condition);

SQLite的INSERT INTO声明

句法:

INSERT INTO table_name( column1,column2....columnN)
VALUES ( value1,value2....valueN);

SQLite的IN子句

句法:

SELECT column1,column2....columnN
FROM   table_name
WHERE  column_name IN (val-1,val-2,...val-N);

SQLite的LIKE子句

句法:

SELECT column1,column2....columnN
FROM   table_name
WHERE  column_name LIKE { PATTERN };

SQLite的NOT IN子句

句法:

SELECT column1,column2....columnN
FROM   table_name
WHERE  column_name NOT IN (val-1,val-2,...val-N);

SQLite的ORDER BY子句

句法:

SELECT column1,column2....columnN
FROM   table_name
WHERE  CONDITION
ORDER BY column_name {ASC|DESC};

SQLite的PRAGMA声明

句法:

PRAGMA pragma_name;

例如:

PRAGMA page_size;
PRAGMA cache_size = 1024;
PRAGMA table_info(table_name);

SQLite的RELEASE SAVEPOINT声明

句法:

RELEASE savepoint_name;

SQLite的REINDEX声明

句法:

REINDEX collation_name;
REINDEX database_name.index_name;
REINDEX database_name.table_name;

SQLite的ROLLBACK语句

句法:

ROLLBACK;
or
ROLLBACK TO SAVEPOINT savepoint_name;

SQLite的保存点声明

句法:

SAVEPOINT savepoint_name;

SQLite的SELECT语句

句法:

SELECT column1,column2....columnN
FROM   table_name;

SQLite的UPDATE语句

句法:

UPDATE table_name
SET column1 = value1,column2 = value2....columnN=valueN
[ WHERE  CONDITION ];

SQLite的真空声明

句法:

VACUUM;
SQLite WHERE Clause:
SELECT column1,column2....columnN
FROM   table_name
WHERE  CONDITION;

赞(0)
未经允许不得转载:srcmini » SQLite的语法

评论 抢沙发

评论前必须登录!