0-------Sql数据库基本操作语句----------
1.显示数据库
show datebase;
2.显示数据库中的表
show tables;
3.显示表的结构
describe 表名;
4.显示表中的记录
select* from 表名;
5.新建数据库
create datebase 数据库名;
6.新建表
create table 表名(数据字段);
字段约束
1.null/ not null
2.default create table t2(id int not null default 0, name varchar(20));
3.zerofill 用0来填充字段前面的位,例如int的数有11位,如果给它赋值7,则结果是0000 0000 007。
4.auto_increment 自动加1
索引
1.primary key
2.unique key
7.增加表全部记录
insert into 表名 values(所有字段);
8.增加表部分记录
insert into 表名(字段1,字段2) values(数据1,数据2);
9.修改表记录
update 表名 set 要修改字段=新数据 where 查找字段=数据;
10.删除记录
delete from 表名 where 查找字段=数据;
11.删除数据库
drop datebase 数据库名;
12.删除表
drop table 表名;
13.数据库登陆
use 数据库名;
14.数据库退出
exit;
15.创建用户
create user happy identified by ‘123456’;
16.删除用户
drop user happy;
17.显示用户权限
show grants for happy;
18. 给用户权限(all这个词可以替换为select,insert, update, delete)
grant all on orders.* to happy;
19. 回收权限
revoke all on orders.* from happy;
20. 修改用户名
rename user happy to happy1;
21. 修改密码
set PASSWORD=password(’654321’);
set password for happy=password(‘123456’);mysql基本语句
最新推荐文章于 2025-11-08 10:45:00 发布
6375

被折叠的 条评论
为什么被折叠?



