@Mysql5.5
启动
mysql -hlocalhost -P3306 -uroot -proot
- show databases;
- use mysql;
- show tables;
- show tables from test;
- 查看当前数据库: select database();
- 建表:
mysql> create table stuinfo(
-> stuid int,
-> stuname varchar(20),
-> gender char,
-> borndate datetime);
- 查看新建表格
show tables;
desc stuinfo;
查看数据: select * from stuinfo;
插入数据:insert into stuinfo values(1,'叶孤城 ',‘男’,‘1998-1-1’);
修改格式:set name gbk;
更新数据:update stuinfo set borndate=‘1980-1-1’ where stuid = 2;
删除数据:delete from stuinfo where stuid = 1;
增加表一列:alter table stuinfo add column email varchar(20);
删除表格:drop table stuinfo;
8.退出
退出:exit;
Tips
1、sql不区分大小写
2、sql也有注释
#
–
/* */