MySQL语句

DDL语句

create   创建

alter   修改

drop   删除

创建表格式   create table 表名(

字段名1 数据类型 约束条件,

字段名2 数据类型 约束条件,

...);

例如:create table student(

id int(20),

name char(40),

age int);

 

添加,修改,删除表字段 格式:

删除字段 alter table 表名 drop 字段;

例如:

alter table student drop age;

查看表结构 show columns from 表名;

例如:

show columns from student;

 

添加字段 alter table 表名 add 字段 数据类型 约束条件;

例如:

alter table student add age int not null;

修改字段 alter table 表名 modify字段名 数据类型 约束条件;

例如:

alter table student modify age int null;

删除表   drop table 表名;

例如:

drop table student;

DML语句

insert   添加

update   修改

delete   删除

添加数据   insert into 表名 values (字段值,字段值,字段值...);

例如:

insert into student values (1,’张三’,18);

添加多行数据   insert into 表名 values (字段值,字段值,字段值...),(字段值,字段值,字段值...),(字段值,字段值,字段值...);

修改数据   update 表名 set 字段=新值 where 条件

例如:

update student set id=2 where name=’张三’;

删除数据   delete from student where 条件

例如:

delete from student where id=1

DCL语句

授权

grant 权限

.表 to '用户' @'IP' identified by '密码';

取消授权  revoke 权限 on 库.表 from '用户' @'IP';

查看某个的用户权限    use mysql;

select * from user where user='用户名称'\G;

查看所有用户权限   select * from user;

 

 

相关推荐

  1. MySQL语句

    2024-07-11 10:42:07       23 阅读
  2. MySQLMySQL基本语句

    2024-07-11 10:42:07       53 阅读
  3. MySQL 系列】MySQL 语句篇_DCL 语句

    2024-07-11 10:42:07       41 阅读
  4. MySQL一 | SQL语句

    2024-07-11 10:42:07       68 阅读
  5. mysql语句练习

    2024-07-11 10:42:07       46 阅读
  6. Mysql的基础语句

    2024-07-11 10:42:07       52 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-11 10:42:07       101 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-11 10:42:07       108 阅读
  3. 在Django里面运行非项目文件

    2024-07-11 10:42:07       91 阅读
  4. Python语言-面向对象

    2024-07-11 10:42:07       98 阅读

热门阅读

  1. Flask+Layui开发案例教程

    2024-07-11 10:42:07       22 阅读
  2. mysql面试题 Day6

    2024-07-11 10:42:07       28 阅读
  3. 人工智能在自动驾驶中的目标检测研究

    2024-07-11 10:42:07       29 阅读
  4. 编程语言 Public:深度解析与未来展望

    2024-07-11 10:42:07       30 阅读
  5. 【SQL】InnoDB中的行锁

    2024-07-11 10:42:07       30 阅读
  6. 编程什么好用:深入剖析编程工具的选择与运用

    2024-07-11 10:42:07       27 阅读
  7. C++引用和指针的区别

    2024-07-11 10:42:07       24 阅读
  8. 3.数组基础

    2024-07-11 10:42:07       21 阅读
  9. Docker 日志丢失 - 解决方案

    2024-07-11 10:42:07       23 阅读