ALTERTABLEtbl_name[alter_specification [, alter_specification]...][partition_options]alter_specification: table_options|ADD[COLUMN]col_namecolumn_definition[FIRST | AFTER col_name]|ADD[COLUMN](col_namecolumn_definition,...)|ADD{INDEX|KEY}[index_name][index_type](key_part,...)[index_option]....
ALTER TABLE employee ADD INDEX (ID) 3、修改表employee中的ID字段为主键PRIMARY KEY ALTER TABLE employee ADD PRIMARY KEY (ID) 4、修改表employee中的ID字段为唯一索引UNIQUE ALTER TABLE employee ADD UNIQUE (ID) 5、将employee表中的id字段重命名为salary并设置其数据类型为int ALTER TABLE employee CHANGE ...
mysql> ALTER TABLE testalter_tbl DROP i; 如果数据表中只剩余一个字段则无法使用DROP来删除字段。 MySQL 中使用 ADD 子句来向数据表中添加列,如下实例在表 testalter_tbl 中添加 i 字段,并定义数据类型: mysql> ALTER TABLE testalter_tbl ADD i INT; 执行以上命令后,i 字段会自动添加到数据表字段的末尾。
: testalter_tbl Type: MyISAM Row_format: Fixed Rows: 0 Avg_row_length: 0 Data_length: 0 Max_data_length: 25769803775 Index_length: 1024 Data_free: 0 Auto_increment: NULL Create_time: 2007-06-03 08:04:36 Update_time: 2007-06-03 08:04:36 Check_time: NULL Create_options: Comment...
table_options 指定了类似于可以在CREATE TABLE语句中使用的表选项,例如ENGINE、AUTO_INCREMENT、AVG_ROW_LENGTH、MAX_ROWS、ROW_FORMAT或TABLESPACE。 但是,ALTER TABLE在作为表选项给出时会忽略DATA DIRECTORY 和 INDEX DIRECTORY。ALTER TABLE只允许它们作为分区选项,并且要求具有FILE权限。
or ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT} or CHANGE [COLUMN] old_col_name create_definition or MODIFY [COLUMN] create_definition or DROP [COLUMN] col_name or DROP PRIMARY KEYor DROP INDEX index_name or RENAME [AS] new_tbl_name or table_options 下面来看几个实例...
--create-options, -a 在CREATE TABLE语句中包括所有MySQL特性选项。(默认为打开状态)--databases, -B 导出几个数据库。参数后面所有名字参量都被看作数据库名。--debug 输出debug信息,用于调试。默认值为:d:t:o,/tmp/mysqldump.trace --debug-check 检查内存和打开文件使用说明并退出。--debug-info 输出调试...
Create_options: Comment: 1 row in set (0.00 sec) # 插入大量数据 mysql> insert into t1 values(1,1); Query OK, 1 row affected (0.00 sec) # 快速加字段 mysql> alter table t1 add column d1 int not null default 0, add column d2 int; ...
To ALTER a table using the PHPMyAdmin tool, please select the table from the list, and then click on the table's 'Operations' tab. There are a variety of alter-table options within the phpMyAdmin interface. The most important options include the possibility to change or delete the existing ...
CREATE TABLE 命令语法比较多,其主要是由表创建定义(create-definition)、表选项(table-options)和分区选项(partition-options)所组成的。 实例1:创建员工表tb_emp1,结构如下表所示。 选择创建表的last_name,创建tb_emp1数据表,输入SQL语句和运行结果如下: ...