IOS development-database-sqlite operation 1

Source: Internet
Author: User
1. sqlite is of weak type. When creating a table, you can choose not to set the field type. Multiple types are used: integer, text, blob, and oc. NSNumber and NSString are supported, NSData2. you can set a field to a primary key and a unique key primary key. A table has only one primary key, and the unique key unique1) sqlite3data. db opens

1. sqlite is of weak type. When creating a table, you can choose not to set the field type. Multiple types are used: integer, text, blob, and oc. NSNumber, NSString, and NSData are supported. you can set a field to a primary key or a unique primary key. A table has only one primary key. The unique key unique 1) sqlite3 data. db opens

1. sqlite is of weak type. You can choose not to set the field type when creating a table. There are several types used: integer, text, blob, and oc that support NSNumber, NSString, and NSData.

2. You can set a field to a primary key or a unique key.

Primary Key. A table has only one primary key. The unique key is unique.

1) sqlite3 data. db open the database and create it if it does not exist

2) view the table in table. quit and exit.

3) create table students (id, name); create a table

However, statements used to create a table are generally written as follows: create table if not exists students (id, name );

Create table students (id integer primary, name text );

Create table students (id integer primary key auto increment, name text );

4) drop table students; delete a table

5) insert into students (id, name) values (1, 'hangzhou'); insert a statement

Insert into students (id) values (2); this is also acceptable, but the name will be NULL. If it is NULL, you can insert '';

Insert into students values (3, 'hangwei'); this is also acceptable, but all fields must be inserted;

6) delete from students; clear the table

Delete from students where id = 2; delete a row

Delete from students where id <2; delete

7) conditional Query

Select * from student;

Select name from student;

Select name from student where id = 2;

Select * from student limit 3;

Select * from student order by id;

Select * from student order by id asc; ascending, default

Select * from student order by id desc; descending order

Select * from student order by id desc limit 3; maximum three

Select count (id) from student;

Select sum (id) from student;

Select avg (id) from student;

Select * from student where id = 3 or id = 5;

8) modify

Update students set name = 'all' where id = 1;

9) copy a table

Create table students2 as select * from students;

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.