常用的sql語句---很全

create database xxx 創建數據庫
use database 切換數據庫

show tables; 查看當前數據庫有哪些table
create table 創建表
alter table add/modify/change 添加一列,添加主鍵外鍵/修改一列/修改列名
rename table to 修改表名
drop table 刪除表
desc table 查看錶結構

insert into xxx values 插入數據
update xxx set xxx=xxx where ...  修改數據
delete from xxx where... 刪除數據
select * from xxx where xxx group by xxx having xxx order by xxx; 查詢數據

truncate table; 摧毀表重建 --- 數據記錄全部刪除 不可恢復

用戶創建和授權
create user xxx identified by 'xxx'; 創建用戶
grant all on *.* to aa;  授予aa用戶所有權限
grant all on customer.* to angel; 授予angel用戶customer數據庫的所有權限
revoke all on *.* from aa; 收回aa的所有權限
發佈了33 篇原創文章 · 獲贊 5 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章