MySQL表管理的命令很多,下面就为您介绍一些最常用的MySQL表管理命令,如果您对MySQL表管理方面感兴趣的话,不妨一看。
#创建数据库
CREATE DATABASE GXDATA DEFAULT CHARACTER SET gb2312;
#创建部门信息表
CREATE TABLE depinfo (
Dep_no CHAR(2) CHARACTER SET gb2312 COLLATE gb2312_chinese_ci NOT NULL,
Dep_name VARCHAR(50) CHARACTER SET gb2312 COLLATE gb2312_chinese_ci NOT NULL,
Dep_Address VARCHAR(50) CHARACTER SET gb2312 COLLATE gb2312_chinese_ci NOT NULL,
Dep_Tel VARCHAR(50) CHARACTER SET gb2312 COLLATE gb2312_chinese_ci NOT NULL
)ENGINE=MyISAM DEFAULT CHARSET=gb2312;
临时表(数据库关闭后自动删除临时表)
CREATE TEMPORARY TABLE table_name(......定义列......)
克隆表
CREATE TEMPORARY TABLE new_table LIKE original_table
根据查询结果建表
CREATE TEMPORARY TABLE table_name SELECT ... ...
查询,改变表存储引擎
SELECT ENGIN FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='database_name' AND TABLE_NAME ='tabne_name'
SHOW TABLE STATUS LIKE 'table_name' G
SHOW CREATE TABLE table_name G
改变存储引擎
ALTER TABLE table_name ENGINE=InnoDB
2014-07-13 16:24:06