美文网首页
SQL 语句总结(至简)

SQL 语句总结(至简)

作者: 周少言 | 来源:发表于2018-06-17 14:52 被阅读0次

DDL—数据定义语言(Create,Alter,Drop,DECLARE)
DML—数据操纵语言(Select,Delete,Update,Insert)
DCL—数据控制语言(GRANT,REVOKE,COMMIT,ROLLBACK)


CREATE

CREATE DATABASE db_name;

DROP

DROP DATABASE db_name;

SHOW

SHOW DATABASES;
SHOW CREATE DATABASE db_name;

USE

USE db_name;


CREATE

CREATE TABLE tb_name(.......);

SHOW

SHOW TABLES;

DESC

DESC db_name;

RENAME

RENAME TABLE tb_name TO new_tb_name;

DROP

DROP TABLE tb_name;

ALTER

修改字段


字段(列)

ALTER MODIFY

ALTER TABLE tb_name MODIFY column ......

ALTER CHANGE

ALTER TABLE tb_name CHANGE column_name new_name

ALTER DROP

ALTER TABLE tb_name DROP column

ALTER ADD

ALTER TABLE tb_name ADD column ......


记录

SELECT FROM

SELECT * FROM tb_name WHERE,,,;

INSERT INTO

INSERT INTO table_name ( field1, field2,...fieldN )
VALUES
( value1, value2,...valueN );

UPDATE SET

UPDATE table_name SET field1=new-value1, field2=new-value2
WHERE Clause

DELETE FROM

DELETE FROM table_name [WHERE Clause]


GRANT

GRANT 权限1,权限2...
ON 对象类型 对象名
TO 用户1,用户2...
(WITH GRANT OPTION) ;

常用操作权限

REVOKE

REVOKE 权限1,权限2...
ON 对象类型 对象名
FROM 用户1,用户2...;

COMMIT

ROLLBACK

相关文章

网友评论

      本文标题:SQL 语句总结(至简)

      本文链接:https://www.haomeiwen.com/subject/objweftx.html