赞
踩
SQL语句
DLL 数据定义语言
create,drop
DML 数据操纵语言
insert,delete,select,update
DCL 数据控制语言
grant,revoke
ALTER TABLE <表名> RENAME <新表名>
- mysql> alter table game_account rename account;
- Query OK, 0 rows affected (0.05 sec)
- mysql> alter table account engine=MyISAM;
- Query OK, 0 rows affected (0.05 sec)
- Records: 0 Duplicates: 0 Warnings: 0
- mysql> show create table account\G;
- *************************** 1. row ***************************
- Table: account
- Create Table: CREATE TABLE `account` (
- `game_name` char(15) NOT NULL,
- `game_password` char(25) NOT NULL
- ) ENGINE=MyISAM DEFAULT CHARSET=latin1
- 1 row in set (0.00 sec)
- ERROR:
- No query specified
ALTER TABLE <表名> ADD <字段名称> <字段定义>
mysql> alter table account add game_sex enum("M","F") not null;
- mysql> alter table account add game_address varchar(20) not null default "huabei" first;
- Query OK, 0 rows affected (0.00 sec)
- Records: 0 Duplicates: 0 Warnings: 0
- mysql> alter table account add game_money int after game_name;
- Query OK, 0 rows affected (0.00 sec)
- Records: 0 Duplicates: 0 Warnings: 0
ALTER TABLE <表名> drop <字段名称>
- mysql> alter table account drop game_wei;
- Query OK, 0 rows affected (0.00 sec)
- Records: 0 Duplicates: 0 Warnings: 0
ALTER TABLE <表名> CHANGE <旧字段> <新字段名称> <字段定义>
- mysql> alter table account change game_zhang wei char(25) not null;
- Query OK, 0 rows affected (0.01 sec)
- Records: 0 Duplicates: 0 Warnings: 0
- mysql> alter table account change wei wei varchar(60) ;
- Query OK, 0 rows affected (0.00 sec)
- Records: 0 Duplicates: 0 Warnings: 0
ALTER TABLE <表名> MODIFY <字段名称> <字段定义>
- mysql> alter table account modify wei int ;
- Query OK, 0 rows affected (0.01 sec)
- Records: 0 Duplicates: 0 Warnings: 0
- mysql> alter table account modify wei int not null ;
- Query OK, 0 rows affected (0.01 sec)
- Records: 0 Duplicates: 0 Warnings: 0
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。