1:查看原始数据库information_schema中的表,并显示出VIEWS表的字段结构属性信息
Show databases;
use information_schema;
desc VIEWS;
2:创建一个offcn数据库,并创建一个students表,字段为id,name,age,phone,height
Create database offcn;
Use offcn;
Create table students (id int,name varchar(4),age varchar(3),plane varchar(11),height varchar(3))
3:查看students表的表结构
Desc students;
4:在上题创建的students表中,随意插入5条数据
Insert into students values(1,‘ls’,‘12’,‘12341234123’,‘123’),(2,‘zs’,‘13’,‘122345123451’,‘124’),(3,‘ww’,‘15’,‘12345612345’,‘125’)(4,‘zp’,‘16’,‘12345671234’,‘126’),(5,‘eg’,‘17’,‘12345678123’,‘127’);
5:查询所有创建的数据
Select * from students;
6:将students表名修改为students_details
Alter table students rename to students_details;
7:将students_details中height字段删除
Alter table students_details drop height;
8:在students_details里添加一个新字段,字段名为sex,并增加两条数据。
Alter table students_details add sex varchar(5);
Update students_details set sex=’man’ where id=2;
Update students_details set sex=’man’ where id=4;
9:删除students_details表
Drop table students_details;
10:删除offcn数据库
Drop database offcn;