mysql基本操作(五)-視圖,用戶管理和索引

student表

1 創建視圖:create view 視圖名 as (select 字段名列表 from 表名);

2 插入數據:insert into 視圖名 values(插入數據);

3 修改數據:update 視圖名 set 待更改是數據 where 條件;

4 刪除數據:delete from stu where 條件;

5 修改視圖:alter view 視圖名 as (select 字段名列表 from 表名);

6 查看視圖:show create view 視圖名;

7 刪除視圖:drop view 視圖名;

索引操作

8 創建表時創建索引:create table 表名 (字段名 字段類型 ,索引類型(字段名))(index()普通索引,unique index 索引名(字段名)唯一性索引, fulltext index 索引名(字段名)全文索引,index 索引名(字段名列表) 多列索引,spatial index 索引名(字段名) 空間索引);

9 在已存在的表上建立索引:create 索引類型 索引名 on 表名(加索引的字段名);(index()普通索引,unique index 索引名(字段名)唯一性索引, fulltext index 索引名(字段名)全文索引,index 索引名(字段名列表) 多列索引,spatial index 索引名(字段名) 空間索引)

10 修改索引:alter table 表名 add 索引類型 索引名(字段名);

11 刪除索引:drop 索引類型 索引名 on 表名;

用戶管理

12 創建用戶:

12.1 create user ‘用戶名’@’localhost’ identified by ‘密碼’;

12.2 grant 權限列表 on . to ‘用戶名’@’localhost’ identified by ‘密碼’;

12.3 insert into(Host,User ,Password,ssl_cipher,x509_subject) values(主機名,用戶名,密碼,”,”) ;

13刪除用戶:

13.1 drop user ‘用戶名’@’localhost’;

13.2 delete from mysql.user where Host=’localhost’ and user=’用戶名’;

14 修改密碼:mysqladmin -u username -p password ‘new_password’(bin目錄下);

15 取消權限:revoke 權限 on . from ‘用戶名’@’localhost’;

16 查看權限:

16.1 select * from user;

16.2 show grants for ‘用戶名’@’localhost’;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章