Sqlite3 actions in iOS

Source: Internet
Author: User


Disclaimer : I have not used all of the following commands, only for the collection, you are welcome to point out the errors
  1. " select  count (*)    from sqlite_master WHERE type= "table" and name = "table_name"                               table_name
  2. " 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
  3. 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
  4. 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;
  5. 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;
  6. 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;
  7. 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;
  8.  " table_name "(First_col integer  ); Create a data table containing a gradual constraint;
  9. < 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;
  10. < 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;
  11. < 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;
  12. alter TABLE  " table_name1 "&NBSP; rename to  " table_name2 ";//Modify Table" Table_name1 "with the name" Table_name2 "
  13. alter TABLE  " table_name "&NBSP;  second_col integer; Add Field second_col
  14. for data table "table_name"
  15. drop table  " table_name ";//delete data table" table_name "
  16.   "table_name"; Deleting a nonexistent data table produces an error, so use if exists to avoid errors;
  17.  " table_name "&NBSP;  select * from" table_name "WHERE first_col > 100; Create a view
  18. DROP VIEW IF EXISTS "view_name";//Delete View


Sqlite3 actions in iOS


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.