Some commonly used SQLite statements

Source: Internet
Author: User

Drop table if exists learning_new4;

Create Table learning_new4 (ID integer default 1 primary key autoincrement, sttile text, scontent text, sort text );

Insert into learning_new4 (sttile, scontent, sort) Select sttile, scontent, sort from learning_new3 order by sort DESC;

// Select some fields from the table and place them in a new table.

Drop table if exists fullnew;

Create Table fullnew (ID integer default 1 primary key autoincrement, stitle varchar (80), scontent memo, sort text );

Insert into fullnew (stitle, scontent, sort) Select field2, field3, field4 from learning_new4 order by field4 DESC;

// Create a new table from an existing table.

Drop table if exists duanxinleyuan;

Create Table duanxinleyuan (ID integer default 1 primary key autoincrement, stitle varchar (80), scontent memo );

Insert into duanxinleyuan (stitle, scontent) Select stitle, scontent from fullnew where ID between 1 and 59;

// Insert the row with the ID between 60 and 140 in fullnew to the end of the existing table.

Insert into duanxinleyuan (stitle, scontent) Select stitle, scontent from fullnew where ID between 60 and 140;

//
If you want to delete the id = 50 ~ 150 records between 100

// Delete row data

Delete from a where chapterid> 49 and chapterid <151

// Reverse orders from existing tables to generate new tables in descending order of IDS

Drop table if exists gui1__des;

Create Table gui1__des (ID integer default 1 primary key autoincrement, stitle varchar (80), scontent memo );

Insert into gui1__des (stitle, scontent) Select stitle, scontent from Guihua order by id desc;

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.