MySQL database operations base
Basic Operation Library
1. Review the current user
select user();
2. Give the current user password
set password = password('123');
Underlying operating table
Create a table
# 创建一个表,名字是t1,id字段(类型int),name字段(类型char(20))
create table t1(id int,name char(20));
#查看t1表详情
desc t1;
: Modify the field
using the change needs to be modified when the field name; when used to modify modify field type
#修改name字段的类型为char(3)
alter table t1 modify name char(3);
#修改name字段的名字为name1,类型为char(3)
alter table t1 change name name1 char(3);
#删除表t1
drop table t1;
Insert Record
表t1中新增两条数据
insert into t1 values(1,'apple1'),(2,'apple2');
insert into t1 (id,name) values (1,'apple1'),(2,'apple2');
#查看数据
select * from t1;
#改
update t1 set name='sb' where id=2;
#删
delete from t1 where id=1;
View current table
select database();