mysql数据库常用语句3
一:查询指定数据库中所有的表名
数据库名:test
select table_name from information_schema.tables where table_schema='test';
如果想查询该schema下的所有信息,只要把table_name修改成 * 即可。
二:查询表结构信息
数据库名:test
表名:employee
SELECT table_schema ,table_name ,column_name ,
column_type , data_type, column_comment FROM information_schema.COLUMNS where
TABLE_SCHEMA like 'test' and TABLE_NAME like 'employee';
三:查询表的创建语句
表名:employee
show create table employee;
四:修改表中字段的描述COMMENT
alter table employee modify id int comment '员工编号';
五:用户管理
grant 普通数据用户,查询、插入、更新、删除 数据库中所有表数据的权利。
grant select on testdb.* to common_user@’%’
grant insert on testdb.* to common_user@’%’
grant update on testdb.* to common_user@’%’
grant delete on testdb.* to common_user@’%’
或者,用一条 MySQL 命令来替代:
grant select, insert, update, delete on testdb.* to common_user@’%’
9>.grant 数据库开发人员,创建表、索引、视图、存储过程、函数。。。等权限。
grant 创建、修改、删除 MySQL 数据表结构权限。
grant create on testdb.* to developer@’192.168.0.%’;
grant alter on testdb.* to developer@’192.168.0.%’;
grant drop on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 外键权限。
grant references on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 临时表权限。
grant create temporary tables on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 索引权限。
grant index on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 视图、查看视图源代码 权限。
grant create view on testdb.* to developer@’192.168.0.%’;
grant show view on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 存储过程、函数 权限。
grant create routine on testdb.* to developer@’192.168.0.%’; -- now, can show procedure status
grant alter routine on testdb.* to developer@’192.168.0.%’; -- now, you can drop a procedure
grant execute on testdb.* to developer@’192.168.0.%’;
10>.grant 普通 DBA 管理某个 MySQL 数据库的权限。
grant all privileges on testdb to dba@’localhost’
其中,关键字 “privileges” 可以省略。
11>.grant 高级 DBA 管理 MySQL 中所有数据库的权限。
grant all on *.* to dba@’localhost’
12>.MySQL grant 权限,分别可以作用在多个层次上。
1. grant 作用在整个 MySQL 服务器上:
grant select on *.* to dba@localhost; -- dba 可以查询 MySQL 中所有数据库中的表。
grant all on *.* to dba@localhost; -- dba 可以管理 MySQL 中的所有数据库
2. grant 作用在单个数据库上:
grant select on testdb.* to dba@localhost; -- dba 可以查询 testdb 中的表。
3. grant 作用在单个数据表上:
grant select, insert, update, delete on testdb.orders to dba@localhost;
4. grant 作用在表中的列上:
grant select(id, se, rank) on testdb.apache_log to dba@localhost;
5. grant 作用在存储过程、函数上:
grant execute on procedure testdb.pr_add to ’dba’@’localhost’
grant execute on function testdb.fn_add to ’dba’@’localhost’
注意:修改完权限以后 一定要刷新服务,或者重启服务,刷新服务用:FLUSH PRIVILEGES。
mysql数据库常用语句3的更多相关文章
- mysql数据库常用语句
关于mysql数据库常用命令的整理: 一:对于数据库的操作 show databases;显示当前用户下所有的数据库名称 use database_name;进入当前数据库 create databa ...
- mysql数据库常用语句2
关于mysql常用语句的整理,上一篇涉及到ddl.dml以及一些简单的查询语句. 1:mysql分页查询 select * from table_name limit 5,10; 从下标为5元素查 ...
- MySql数据库常用语句汇总
第一天1.登陆数据库 mysql -uroot -proot; //-u用户名 -p密码2.启动数据库 net start mysql;3.创建表空间(数据库)create database qy97 ...
- mysql数据库常用语句系列
mysql查询某个字段长度 一般查询语句:SELECT `lcontent` FROM `caiji_ym_liuyan` 查询数据: 有些时候需要查询某个字段的长度为多少时候才显示数据: SQL ...
- (转载)常用的Mysql数据库操作语句大全
打开CMD,进入数据库命令:mysql -hlocalhost -uroot -p 退出数据库:exit 用户管理: 1.新建用户: >CREATE USER name IDENTIFIED B ...
- MySQl数据库常用的DOS命令
MySQl数据库常用的DOS命令.. 这是第一部分.. 数据库的连接信息:jdbc:mysql://localhost:3306/shxtcom.mysql.jdbc.Driver /*jdbc:sq ...
- MySQL 数据库常用命令小结
MySQL 数据库常用命令 1.MySQL常用命令 create database name; 创建数据库 use databasename; 选择数据库 drop database name 直接删 ...
- java数据库 JDBC操作MySQL数据库常用API 部门表和员工表 创建表 添加数据 查询数据
package com.swift.department; import java.sql.Connection; import java.sql.PreparedStatement; import ...
- MySQL 数据库SQL语句——高阶版本2
MySQL 数据库SQL语句--高阶版本2 实验准备 数据库表配置: mysql -uroot -p show databases; create database train_ticket; use ...
随机推荐
- UPC OJ 一道水题 STL
Problem C: 字符串游戏 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 10 Solved: 3 [Submit][Status][Web ...
- 房租管理小软件(六):通用功能包括时间,效验,MD5加密,XML 操作
1.时间相关 public static DateTime getNow() { MyFZDataContext dataContext = MyFZDataContext.getDataContex ...
- HTTP DNS小结
https://www.dnspod.cn/httpdns/guide HttpDNS是使用HTTP协议向DNS服务器的80端口进行请求,代替传统的DNS协议向DNS服务器的53端口进行请求,绕开了运 ...
- SQL Server: Difference Between Locking, Blocking and Dead Locking
Like ever, today’s article of Pinal Dave was interesting and informative. After, our mutual discussi ...
- 5.1 CUDA atomic原子操作
和许多多线程并行问题一样,CUDA也存在互斥访问的问题,即当一个线程改变变量X,而另外一个线程在读取变量X的值,执行原子操作类似于有一个自旋锁,只有等X的变量在改变完成之后,才能执行读操作,这样可以保 ...
- [原创]git使用入门
创建git项目并初始化 建立一个新文件夹,然后将该文件夹定义为git项目 Lilis-MacBook-Pro:GitDir lili$ mkdir testgit Lilis-MacBook-Pro: ...
- 【bzoj1300】大数计算器
题意: 求C(n,m) 如果C(n,m)的位数<=12 那么直接输出 否则按XXX...XXXXXXXXX的形式输出 题解: 这题之前打过 但是昨天又想出一种新的做法 先说下新的做法吧- - _ ...
- ABAP开发基础知识:内表(Internal Table)
http://www.cnblogs.com/foxting/archive/2012/03/19/2406830.html 内表与结构体基本类似,它同样是程序运行中被临时创建的一个存储空间,它是一个 ...
- A Tour of Go Switch with no condition
Switch without a condition is the same as switch true. This construct can be a clean way to write lo ...
- 转载 HTTP常见状态码分析 200 301 302 404 500
转载原地址: http://www.cnblogs.com/starof/p/5035119.html HTTP状态码(HTTP Status Code) 一些常见的状态码为: 一.1开头1xx(临 ...