Disclaimer : I have not used all of the following commands, only for the collection, you are welcome to point out the errors
-
- " select count (*) from sqlite_master WHERE type= "table" and name = "table_name" table_name
-
- " select name, sql from Sqlite_master WHERE type= "table" and name = "table_name" // This statement is said to return the statement that created "table_name", yes, the statement, which of course contains "table_name" for each field name
-
- select * FROM" table_name ", [rs columnnameforindex:i] //RS is the result set returned, which returns the field name of index = = i, yes, the field name
- CREATE TABLE "table_name" (First_col integer)//creation data table; CREATE TABLE"table_name" (First_col integerDEFAULT0, Second_col varcharDEFAULT' Hello ')//Create data table, First_col field has default value;
-
- 1) ATTACH DATABASE ' d:/mydb.db ' mydb//Current link is a" d:/mydb.db "database, after which the operation will be in effect 2. Exit//exits the current database;
- create TABLE IF not EXISTS " table_name "(First_col integer)//If the created" table_name "already exists, there will be a conflict, resulting in statement execution failure, if NOT exists can avoid this error;
- CREATE TABLE"Table_name2"As SELECT * from"table_name1";//The statement will be created in accordance with the TABLE_NAME1 mode table_name2, without primary KEY constraints and default values; Use the . Schema "Table_name2" You can return the statement that created the data table;
-
- " table_name "(First_col integer ); Create a data table containing a gradual constraint;
- < Span style= "LINE-HEIGHT:28PX; font-family: ' Hiragino Sans GB W3 ', ' Hiragino Sans GB ', arial,helvetica,simsun,u5b8bu4f53 ' >create TABLE " table_name "&NBSP; (First_col integer ); Create a table that contains field value uniqueness constraints;
- < Span style= "LINE-HEIGHT:28PX; font-family: ' Hiragino Sans GB W3 ', ' Hiragino Sans GB ', arial,helvetica,simsun,u5b8bu4f53 ' >create TABLE " table_name "&NBSP; (First_col integer ); Creates a table that contains a constraint that the field value is forbidden to be null;
- < Span style= "LINE-HEIGHT:28PX; font-family: ' Hiragino Sans GB W3 ', ' Hiragino Sans GB ', arial,helvetica,simsun,u5b8bu4f53 ' >create TABLE " table_name "&NBSP; (First_col integer (First_col < 5)); Create a table that contains field value range constraints;
-
- alter TABLE " table_name1 "&NBSP; rename to " table_name2 ";//Modify Table" Table_name1 "with the name" Table_name2 "
-
- alter TABLE " table_name "&NBSP; second_col integer; Add Field second_col
for data table "table_name"
-
- drop table " table_name ";//delete data table" table_name "
-
- "table_name"; Deleting a nonexistent data table produces an error, so use if exists to avoid errors;
- " table_name "&NBSP; select * from" table_name "WHERE first_col > 100; Create a view
-
- DROP VIEW IF EXISTS "view_name";//Delete View
Sqlite3 actions in iOS