SQLite Using tutorial 2 syntax

Source: Internet
Author: User
Tags glob savepoint sqlite sqlite create table



Http://www.runoob.com/sqlite/sqlite-syntax.html





SqliteGrammar


SQLite follows a unique set of rules and guidelines called grammar. This tutorial lists all the basic SQLite grammars and gives you a quick start to SQLite.


Case sensitivity


One important point to note is that SQLite is case insensitive, but some commands are case-sensitive, such as GLOB and GLOB have different meanings in SQLite's statements.


Comments


SQLite annotations are additional annotations that you can add to your SQLite code to make them more readable, and they can appear in any space, including in the middle of an expression and other SQL statements, but they cannot be nested.



The SQL comment starts with two consecutive "-" characters (ASCII 0x2d) and expands to the next newline character (ASCII 0x0a) or until the input ends, whichever is first.



You can also use C-style annotations to start with "/*" and extend to the next "*/" character pair or until the input ends, whichever is the first. SQLite annotations can span multiple lines.


Sqlite>.help--This was a single line comment




SQLite statements


All SQLite statements can start with any keyword, such as SELECT, INSERT, UPDATE, DELETE, ALTER, DROP, and so on, all of the statements end with a semicolon (;).


SQLite ANALYZE Statement:
Analyze;oranalyze Database_name;oranalyze Database_name.table_name;




SQLite and/or clause:
SELECT column1, Column2....columnnfrom   table_namewhere  CONDITION-1 {and|or} CONDITION-2;




SQLite ALTER TABLE Statement:
ALTER TABLE table_name ADD COLUMN column_def ...;




SQLite ALTER TABLE Statement (Rename):
ALTER TABLE table_name RENAME to new_table_name;




SQLite ATTACH DATABASE Statement:
ATTACH DATABASE ' DatabaseName ' as ' alias-name ';




SQLite BEGIN TRANSACTION Statement:
Begin;orbegin EXCLUSIVE TRANSACTION;




SQLite between clause:
SELECT column1, Column2....columnnfrom   table_namewhere  column_name between Val-1 and Val-2;




SQLite COMMIT Statement:
COMMIT;




SQLite CREATE INDEX Statement:
CREATE INDEX index_name on table_name (column_name COLLATE nocase);




SQLite CREATE UNIQUE INDEX statement:
CREATE UNIQUE INDEX index_name on table_name (column1, Column2,... columnn);




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




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




SQLite CREATE VIEW Statement:
CREATE VIEW database_name.view_name  asselect statement ...;




SQLite CREATE VIRTUAL TABLE statement:
CREATE virtual table Database_name.table_name USING weblog (access.log); orcreate virtual Table Database_name.table_name USING Fts3 ();




SQLite COMMIT TRANSACTION Statement:
COMMIT;




SQLite COUNT clause:
SELECT COUNT (column_name) from   table_namewhere  CONDITION;




SQLite DELETE Statement:
DELETE from Table_namewhere  {CONDITION};




SQLite DETACH DATABASE Statement:
DETACH DATABASE ' Alias-name ';




SQLite DISTINCT clause:
SELECT DISTINCT column1, Column2....columnnfrom   table_name;




SQLite DROP INDEX Statement:
DROP INDEX Database_name.index_name;




SQLite DROP TABLE Statement:
DROP TABLE Database_name.table_name;




SQLite DROP VIEW Statement:
DROP INDEX Database_name.view_name;




SQLite DROP TRIGGER Statement:
DROP INDEX Database_name.trigger_name;




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




SQLite EXPLAIN Statement:
EXPLAIN INSERT statement...;or EXPLAIN QUERY PLAN SELECT statement ...;




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




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




SQLite has a clause:
SELECT SUM(column_name)
FROM   table_name
WHERE  CONDITION
GROUP BY column_name
HAVING (arithematic function condition);




SQLite INSERT into statement:
INSERT into table_name (column1, COLUMN2....COLUMNN) VALUES (value1, Value2....valuen);




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




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




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




SQLite ORDER BY clause:




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




SQLite PRAGMA Statement:
PRAGMA pragma_name;

For example:

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




SQLite RELEASE savepoint Statement:
RELEASE savepoint_name;




SQLite REINDEX Statement:
REINDEX collation_name; REINDEX Database_name.index_name; REINDEX Database_name.table_name;




SQLite ROLLBACK Statement:
Rollback;orrollback to SavePoint Savepoint_name;




SQLite savepoint Statement:
SavePoint savepoint_name;




SQLite SELECT Statement:
SELECT column1, Column2....columnnfrom   table_name;




SQLite UPDATE Statement:
UPDATE table_nameset column1 = value1, Column2 = value2....columnn=valuen[WHERE  CONDITION];




SQLite VACUUM Statement:
VACUUM;




SQLite WHERE clause:
SELECT column1, Column2....columnnfrom   table_namewhere  CONDITION;








SQLite using tutorial 2 syntax


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.