dcs68林淼森 发表于 2021-11-21 22:30:47

11.21数据库指令笔记

1、create创建 alter增加修改 drop删除 desc查询
2、create table aaa(id int(2)primary key auto_increment,name char(6),class int(2));
    创建表增加带主键和自增长的字段
3、alter table aaa add(id int(4),name char(6));同时增加多个字段
4、alter table aaa drop id;删除aaa表中的id字段
5、alter table aaa drop id,drop name,drop age,drop class;同时删除多个字段
6、drop table aaa;删除aaa这个表
7、alter table aaa change id int(2)primary key;增加主键
8、alter table aaa change id int(2)auto_increment;增加自增长
9、alter table aaa change id id int(5); 给aaa中的id修改类型为int(5)
10、alter table aaa drop primary key;删除aaa中的主键
11、insert into=插入数据   select * from+表=查询    delete from+表=删除
12、insert into增;   delete from删;   update set改;   select from查;
13、insert into aaa(id,name,class,scroe)values(1,'xiaoming',7,89)
    为aaa表中增加表结构和表数据
14、insert intu aaa values(3,'xiaoliu',8,90),(4,'jizai',7,80),(5,'aqiang',9,77);
    为aaa表中增加多行新的数据
15、insert into aaa(age,class)values(13,7),(14,6),(13,5);
    为aaa表中的年龄和教室增加多条数据
16、delete from aaa where id=3; 删除aaa表中id=3这一行的数据
17、delete from aaa;和truncate aaa同用,删除整个表中所有数据,不能删结构(删结构用dorp table)
18、update aaa set name='xiaolin' where id=1 把id这一行的名字改为xiaolin
19、update aaa set age=18; 把aaa表中的年龄全部改为18
20、select * from aaa;查询aaa表中的所有内容
21、select * from aaa where age=18; 查询年龄等于18的所有内容
22、select * from aaa where agr=20 and scroe=91;查询满足条件(二十岁考了91分)的数据
23、select * from aaa where age>15;大于15岁的所有信息
    select * from aaa where scroe<90;分数小于90分的所有信息
    select * from aaa where age=30;等于30岁的所有信息
    select * from aaa where scroe>=80;分数大于等于80的所有信息
    select * from aaa where age<=20;小于等于20岁的所有信息
    select * from aaa where acroe!=30;不包含30分的所有信息
24、select * from aaa where age in(18,19,20);查询18 19 20岁的信息 有就显示 无就不显示
25、select * from aaa where name=‘liu’;查找aaa表中的liu
26、select agr from aaa where name='lin';查找lin的年龄
页: [1]
查看完整版本: 11.21数据库指令笔记