SQL语句总结 1.SQL 语句不区分大小写,关键字大写处理 2.SQL 语句中的命名不能喝关键字冲突 3.每条语句都以;结束。 4. DDL:数据定义型语言 1)创建表:CREATE TABLE studentTable (name text,identify text,age integer); 2)删除表:DROP TABLE movieTable; 5.DML:数据操作型语言 1)插入一行数据:INSERT INTO studentTable(name,identify,age) VALUES('Jerry','1102',40); 2)更新一行数据:UPDATE studentTable SET age=100 WHERE identify=1000; 3)删除一行数据:DELETE from studentTable WHERE age<100 and name=‘Tom’; 6.DQL: 数据查询型语言 1)查询所有 SELECT * from studentTable; 2)查询某些字段,查询多个字段时用逗号分隔, SELECT name,age from studentTable; 3)条件查询 SELECT * from studentTable WHERE age<70 4)查询符合条件的数据个数 select count(*) from studentTable WHERE age<70; 5)排序查询 select * from studentTable order by age desc;降序 select * from studentTable order by age asc; 升序(默认) 6)模糊查询 SELECT * from studentTable WHERE name LIKE ‘%r%’; %代表通配符,表示没有或者一个或者多个 7.设置约束 主键约束:CREATE TABLE movieTable(id integer PRIMARY KEY AUTOINCREMENT,name text,directorid integer); 8.多表联查 SELECT * from movieTable m JOIN dierctorTable d ON m.directorid=d.id WHERE m.name=‘多啦A梦'; movieTable别名m dierctorTable别名d JOIN表示联表 ON表示两个表的字段的联系:即movie表中的director字段和 directorid表中的id字段建立关联。 id为外键。查询时会显示movie表和director表的所有信息。