更新表的存储引擎:
ALTER TABLE tb TYPE=MYISAM/INNODB

创建表时最好确认表不存在:
CREATE TABLE IF NOT EXISTS
在数据表优化查询时,常用到临时表
可用CREATE TEMPORARY TABLE 来创建临时表,这些表在会话结束时会自动消失,使用临时表不必费心发布drop table 语句明确删除这些表
可利用select来创建一个表
CREATE TABLE new_tb SELECT * FROM tb;
添加索引方法:
ALTER TABLE tb_name ADD INDEX index_name (column_list);
ALTER TABLE tb_name ADD UMIQUE index_name (column_list);
ALTER TABLE tb_name ADD PRIMARY KEY (column_list);
or
CREATE UNIQUE INDEX index_name ON tb_name(column_list);
CREATE INDEX index_name ON tb_name (column_list);
(不能用CREATE INDEX语句创建PRIMARY KEY索引)
CREATE TABLE tb_name(
INDEX index_name(column_list),
UNIQUE index_name (column_list),
PRIMARY KEY (column_list),
)
创建基于列前缀的索引
CREATE TABLE tb_name(
name CHAR(30),
address CHAR(60),
INDEX index_name(name,address)
)
CREATE TABLE tb_name(
name CHAR(30),
address CHAR(60),
INDEX index_name(name(10),address(20))
)
删除索引:
DROP INDEX index_name ON tb_name
ALTER TABLE tb_name DROP INDEX index_name
ALTER TABLE tb_name DROP PRIMARY KEY

更新表的存储引擎:

ALTER TABLE tb TYPE=MYISAM/INNODB
创建表时最好确认表不存在:

CREATE TABLE IF NOT EXISTS
在数据表优化查询时,常用到临时表可用CREATE TEMPORARY TABLE 来创建临时表,这些表在会话结束时会自动消失,使用临时表不必费心发布drop table 语句明确删除这些表
可利用select来创建一个表

CREATE TABLE new_tb SELECT * FROM tb;
添加索引方法:

ALTER TABLE tb_name ADD INDEX index_name (column_list);

ALTER TABLE tb_name ADD UMIQUE index_name (column_list);

ALTER TABLE tb_name ADD PRIMARY KEY (column_list);

or

CREATE UNIQUE INDEX index_name ON tb_name(column_list);

CREATE INDEX index_name ON tb_name (column_list);(不能用CREATE INDEX语句创建PRIMARY KEY索引)
CREATE TABLE tb_name( INDEX index_name(column_list), UNIQUE index_name (column_list), PRIMARY KEY (column_list), …)
创建基于列前缀的索引

CREATE TABLE tb_name(

Aback to I shampoo pressure my matter him much very white. But are mess the is guess hair the on! The leave down are final not it, not have very and. Home With overpowering but very. Around crystal/glass fairly used Aveeno are on read with have as only.

name CHAR(30), address CHAR(60), INDEX index_name(name,address) …)

CREATE TABLE tb_name( name CHAR(30), address CHAR(60), INDEX index_name(name(10),address(20)) …)
删除索引:

DROP INDEX index_name ON tb_nameALTER TABLE tb_name

DROP INDEX index_nameALTER TABLE tb_name DROP PRIMARY KEY

Samsung has been accused of participating in bribery and corruption to the tune of $25 million in order to gain influence with choi soon-sil, the friend of the recently impeached president of south korea, park geun-hye Japanese society invests heavily in english-language https://www.pro-essay-writer.com/ education

标签: ,
本文连接地址: http://www.fresker.com/archives/288 (转载注明出处)

回复

目前暂无评论

Sorry, 评论已关闭.