杭州做网站哪家最好莱芜雪野湖酒店
修改数据库表存储引擎


show create table dept;
 show table status from itpux where name ='s2'\G;
 select * from information_schema.`TABLES` where table_schema='itpux' and table_name='s3';
 查询整个mysql里面存储引擎是innodb/myisam的表

建表时候要写好存储引擎
-- 创建表
 -- 表名,表字段名,表字段的定义
 -- create table table_name 列定义 选项。
 -- create table table_name like old_table_name --like:包括旧表的结构+索引
 -- create table table_name as select * from old_table_name; --as 包括酒标的结构信息。
 -- 通用语法
 -- create table table_name(colume_name colume_type);
 -- 案例
 create table itpuxt1(
     id int(20) unsigned auto_increment not null,
     name varchar(20) not null, 
     jobdate date,
     primary key(id)
 )engine=innodb default charset=utf8;
 show create table itpuxt1;
-- 查询表
 show tables;
 show tables from db_name;
 show tables like '关键字';
 show tables from mysql;
 show tables like 'it%';
 select *from dept;
 select *from dept limit 2;
 select COUNT(*) from dept;
-- 查看表结构
 use itpux;
 show tables;
 desc itpuxt1;

-- 删除表
show tables;
 drop table s1;
 drop table s2,s3;

表的重命名
rename table a1 to a2;
 show tables;



-- 截断表
 truncate table t_name;
 create table itpuxt4 select * from dept;
 select * from  itpuxt4;

truncate和drop区别,truncate 是将数据删掉,表重建;drop是把数据和表定义全部删掉;
修改表结构,增加列

同时增加两个列

删除列

重命名列

修改表字段定义

-- 修改表的字符集
 alter table itpuxt1 character set utf8; -- 有数据时不要改字符集,无数据时可更改字符集
通过视图形式创建表

添加索引

自动生成创建表语句

