mysql命令
DDL-数据定义语言
Data Definition Language 数据定义语言
create
创建数据库及其对象(包括 新建表、索引、视图、存储过程)
alter
改变现有数据库的结构(包括 修改索引、修改字段类型、删除索引)
truncate
删除表中所有记录,并删除已分配的空间
comment
添加注释
rename
重命名(包括 索引,表名)
DML-数据操作语言
Data Manipulation Language 数据操作语言
select
从数据库中检索数据
insert
新增数据到数据库中
update
更新表格中现有数据
delete
删除现有数据
explain
查看语句的执行计划
lock table
锁表操作
DCL-数据控制语言
Data Control Language 数据定义语言
grant
允许访问数据库的权限
desc mysql.user;
SELECT user,HOST from mysql.user;
show GRANTs for 'pingtai_grd'@'10.%.%.%' ;
GRANT select ON `sp-databus`.* TO 'pingtai_grd'@'10.%.%.%';
revoke
撤销访问数据库的权限
TCL-事务控制语言
Transaction Control Language 事务控制语言
TCL语句 只有在DML语句上有效,在DDL语句上无效
commit
提交事务
rollback
回滚事务
set trasaction
设置事务隔离级别
other
show
root@((none))11:00:04>help mysql
Nothing found
Please try to run 'help contents' for a list of all accessible topics
root@((none))11:01:41>help show
Name: 'SHOW'
Description:
SHOW has many forms that provide information about databases, tables,
columns, or status information about the server. This section describes
those following:
SHOW {BINARY | MASTER} LOGS
SHOW BINLOG EVENTS [IN 'log_name'] [FROM pos] [LIMIT [offset,] row_count]
SHOW CHARACTER SET [like_or_where]
SHOW COLLATION [like_or_where]
SHOW [FULL] COLUMNS FROM tbl_name [FROM db_name] [like_or_where]
SHOW CREATE DATABASE db_name
SHOW CREATE EVENT event_name
SHOW CREATE FUNCTION func_name
SHOW CREATE PROCEDURE proc_name
SHOW CREATE TABLE tbl_name
SHOW CREATE TRIGGER trigger_name
SHOW CREATE VIEW view_name
SHOW DATABASES [like_or_where]
SHOW ENGINE engine_name {STATUS | MUTEX}
SHOW [STORAGE] ENGINES
SHOW ERRORS [LIMIT [offset,] row_count]
SHOW EVENTS
SHOW FUNCTION CODE func_name
SHOW FUNCTION STATUS [like_or_where]
SHOW GRANTS FOR user
SHOW INDEX FROM tbl_name [FROM db_name]
SHOW MASTER STATUS
SHOW OPEN TABLES [FROM db_name] [like_or_where]
SHOW PLUGINS
SHOW PROCEDURE CODE proc_name
SHOW PROCEDURE STATUS [like_or_where]
SHOW PRIVILEGES
SHOW [FULL] PROCESSLIST
SHOW PROFILE [types] [FOR QUERY n] [OFFSET n] [LIMIT n]
SHOW PROFILES
SHOW RELAYLOG EVENTS [IN 'log_name'] [FROM pos] [LIMIT [offset,] row_count]
SHOW SLAVE HOSTS
SHOW SLAVE STATUS [FOR CHANNEL channel]
SHOW [GLOBAL | SESSION] STATUS [like_or_where]
SHOW TABLE STATUS [FROM db_name] [like_or_where]
SHOW [FULL] TABLES [FROM db_name] [like_or_where]
SHOW TRIGGERS [FROM db_name] [like_or_where]
SHOW [GLOBAL | SESSION] VARIABLES [like_or_where]
SHOW WARNINGS [LIMIT [offset,] row_count]
like_or_where:
LIKE 'pattern'
| WHERE expr
If the syntax for a given SHOW statement includes a LIKE 'pattern'
part, 'pattern' is a string that can contain the SQL % and _ wildcard
characters. The pattern is useful for restricting statement output to
matching values.
Several SHOW statements also accept a WHERE clause that provides more
flexibility in specifying which rows to display. See
http://dev.mysql.com/doc/refman/5.7/en/extended-show.html.
URL: http://dev.mysql.com/doc/refman/5.7/en/show.html
show databases;
查看当前存在数据库
获得当前数据库内的可用表
use information_schema;
show tables;
获得当前数据库内的可用表的列表的结构
use information_schema;
show columns from files; --describe files;
show status; 显示服务器状态信息
show create database xx; 显示创建特定数据库的MySQL语句
`` MySQL的转义符
show create table xx; 显示创建特定表的MySQL语句
show errors; 显示服务器错误信息
show warnings; 显示服务器警告信息
学编程 https://www.lanmper.cn/mysql/t7933