数据表的基本操作 (相当于文件中的EXCEL)
1.查看数据表 show tables;
2.查看表中数据 select * from <table name>; select * from stuinfo;
3.创建数据表 create table <tablename> (<field name> <field type>,<field name> <field type>,<field name> <field type>,...);
create table StuInfo(
StuId varchar(10) primary key,
StuName varchar(10),
gender char(1),
class varchar(10),
city varchar(10));
4.查看表结构 describe <tablename>; describe StuInfo;
5.修改数据表 alter table <tablename> add/drop <field name> <field type>
alter table StuInfo add Major varchar(10);
alter table StuInfo drop Major;
6.删除数据表 drop table <tablename> drop table StuInfo;
7.更改表中数据 update <tablename> set <filed name> =<new value> where <>
update StuInfo set city = 'Beijing' where StuId = '20200101';
8.删除表中数据 delete from <table name> where
delete from StuInfo where StuId = '20200101';
9.增加表中数据