Your browser does not support the Canvas element.

初始mysql语句

操作文件夹(库)

create database db1 charset utf8;

# 查看当前创建的数据库
show create database db1;
# 查看所有的数据库
show databases;

alter database db1 charset gbk;

drop database db1;

 


 

操作文件(表)

use db1; #切换文件夹

select database(); #查看当前所在文件夹

create table t1(id int,name char);

查 

#查看当前的这张t1表
show create table t1;

# 查看所有的表
show tables;

# 查看表的详细信息
desc t1;

# modify修改的意思
alter table t1 modify name char(6);
# 改变name为大写的NAME
alter table t1 change name NAMA char(7);

# 删除表
drop table t1;

 

 

操作文件内容(记录)

 增

# 插入一条数据,规定id,name数据leilei
insert t1(id,name) values(1,"mjj01"),(2,"mjj02"),(3,"mjj03");

 查

select id from db1.t1;
select id,name from db1.t1;
select * from db1.t1; 

update db1.t1 set name='zhangsan';
update db1.t1 set name='alex' where id=2;

 删

delete from t1;
delete from t1 where id=2;

 

 
 
 
posted @ 2018-09-17 22:23  一根小菜  阅读(133)  评论(0编辑  收藏  举报
Your browser does not support the Canvas element.