创建一个表:
mysql> create table students (
-> sno char(10) primary key,
-> sname char(8) not null,
-> ssex char(1) not null check(ssex = 'f' or ssex = 'm'),
-> sage int not null,
-> sdept char(20) default 'computer'
-> )
-> ;
mysql所支持的字符类型:
修改表结构:
mysql> alter table students change sage sage int unsigned;
mysql> alter table students add grade1 int not null default '1';
删除一个字段:
mysql> alter table students drop grade1 ;
表重命名:
mysql> alter table students rename students2;
数据库存储引擎类型:
存储引擎:相当于一个插件,,mysql跟存储在磁盘上的文件进行交互的接口。
*************************** 1. row ***************************
engine: innodb(行级别锁 粒度比较小)
support: yes
comment: supports transactions, row-level locking, and foreign keys
transactions: yes
xa: yes
savepoints: yes
*************************** 2. row ***************************
engine: mrg_myisam
support: yes
comment: collection of identical myisam tables
transactions: no
xa: no
savepoints: no
*************************** 3. row ***************************
engine: blackhole
support: yes
comment: /dev/null storage engine (anything you write to it disappears)
transactions: no
xa: no
savepoints: no
*************************** 4. row ***************************
engine: csv
support: yes
comment: csv storage engine
transactions: no
xa: no
savepoints: no
*************************** 5. row ***************************
engine: memory
support: yes
comment: hash based, stored in memory, useful for temporary tables
transactions: no
xa: no
savepoints: no
*************************** 6. row ***************************
engine: federated
support: no
comment: federated mysql storage engine
transactions: null
xa: null
savepoints: null
*************************** 7. row ***************************
engine: archive
support: yes
comment: archive storage engine
transactions: no
xa: no
savepoints: no
*************************** 8. row ***************************
