作者:智亚康-Scorpio | 来源:互联网 | 2023-09-17 13:18
联系人:石虎QQ:1224614774昵称:嗡嘛呢叭咪哄*简单约束*CREATETABLEIFNOTEXISTSt_student(idINTEGERPRIMARYKEYAUTOI
//联系人:石虎QQ: 1224614774昵称:嗡嘛呢叭咪哄
/*简单约束*/
CREATE TABLE IF NOT EXISTS t_student(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER);
CREATE TABLE IF NOT EXISTS t_student(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOTNULL, age INTEGER NOTNULL);
CREATE TABLE IF NOT EXISTS t_student(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT UNIQUE, age INTEGER);
CREATE TABLE IF NOT EXISTS t_student(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER DEFAULT1);
/*分页*/
SELECT * FROM t_student ORDER BY id ASC LIMIT30,10;
/*排序*/
SELECT * FROM t_student WHERE score >50ORDER BY age DESC;
SELECT * FROM t_student WHERE score <50ORDER BY age ASC , score DESC;
/*计量*/
SELECT COUNT(*) FROM t_student WHERE age >50;
/*别名*/
SELECT name as myName, age as myAge, score as myScore FROM t_student;
SELECT name myName, age myAge, score myScore FROM t_student;
SELECT s.name myName, s.age myAge, s.score myScore FROM t_student s WHERE s.age >50;
/*查询*/
SELECT name, age, score FROM t_student;
SELECT * FROM t_student;
/*修改指定数据*/
UPDATE t_student SET name =&#8217;MM&#8217;WHERE age =10;
UPDATE t_student SET name =&#8217;WW&#8217;WHERE age is7;
UPDATE t_student SET name =&#8217;XXOO&#8217;WHERE age <20;
UPDATE t_student SET name =&#8217;NNMM&#8217;WHERE age <50and score >10;
/*删除数据*/
DELETE FROM t_student;
/*更新数据*/
UPDATE t_student SET name =&#8217;gq&#8217;;
/*插入数据*/
INSERT INTO t_student(name, age) VALUES(&#8216;hml2&#8217;,32);
INSERT INTO t_student(name) VALUES(&#8216;hml2&#8217;);
INSERT INTO t_student(age, name) VALUES(33,&#8217;hml3&#8242;);
/*插入数据*/
INSERT INTO t_student(name, age, score) VALUES (&#8216;lee&#8217;,&#8217;28&#8217;,100);
/*添加主键*/
CREATE TABLE IF NOT EXISTS t_student (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, score REAL);
/*添加主键*/
CREATE TABLE IF NOT EXISTS t_student (id INTEGER, name TEXT, age INTEGER, score REAL, PRIMARY KEY(id));
/***********************DDL************************/
/*删除表*/
DROP TABLE IF EXISTS t_student;
DROP TABLE t_student;
/*创建表*/
CREATE TABLE IF NOT EXISTS t_student(name TEXT, age INTEGER, id INTEGER PRIMARY KEY AUTOINCREMENT);
CREATE TABLE t_student(name TEXT, age INTEGER, id INTEGER PRIMARY KEY AUTOINCREMENT);
CREATE TABLE t_student(name TEXT, age INTEGER, id INTEGER PRIMARY KEY);
CREATE TABLE t_student(name TEXT, age INTEGER, id INTEGER, PRIMARY KEY(id));
CREATE TABLE t_student(name TEXT, age INTEGER, id INTEGER );