1.查看表格的各個欄位型別
describe table_name
desc table_name
2.給表名重命名
rename table 原表名 to 新表名;
3.mysql查詢超時解決
select /+QUERY_TIMEOUT(150000000000)/ * from table_name
sql加上+/+QUERY_TIMEOUT(150000000000)/
4.查看索引
show index from table_name
5.創建普通索引
create index 索引名 on 表名(欄位名)
alter table 表名 add index 索引名(欄位名)
6.創建聯合索引
alter table 表名 add index 索引名(欄位名1, 欄位名2)
7.創建主鍵索引
alter table 表名 add primary key(欄位名)
8.洗掉索引
drop index index_name on table_name
alter table 表名 drop index 索引名
9.創建唯一索引
create unique index 索引名 on 表名(欄位名);
10.group by 具有去重的功能
11.能用sql陳述句解決的問題盡量使用sql解決問題,而不要寫代碼,
12.洗掉表的操作
drop table if exists stu;
13.使用alter給表添加欄位
ALTER TABLE 【表名】 ADD 【列名】 【型別】
alter table table1 add transactor varchar(10) not Null;
14.使用alter洗掉表的欄位
ALTER TABLE 【表名】 DROP 【列名】
15.使用alter修改列名
ALTER TABLE 【表名】 CHANGE 【列名】【新名】
16.修改表名
ALTER TABLE tbl_name rename new_tbl_name;
17.使用explain分析查詢的sql陳述句,查看sql的查詢效率,
explain select 陳述句
desc select 陳述句
18.創建表一定給每個欄位加注釋,通過comment '注釋’
19.mysql資料庫表,主鍵的查詢效率和速度是大于普通索引的,
20.今天建的索引,明天才能生效呢,
21.處理大資料量資料,使用磁區、分表、分庫操作,
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/234315.html
標籤:其他
上一篇:SQL:資料庫更新陳述句操作實體
下一篇:MySQL學習筆記.資料庫完整性
