alter table tbl_name add col_name type
mysql>alter table pet add weight int;
alter table tbl_name drop col_name
mysql>alter table pet drop weight;
alter table tbl_name modify col_name type
mysql>alter table pet modify weight varchar(30);
alter table tbl_name change old_col_name col_name type
alter table pet change weight weight varchar(30);
alter table tbl_name change old_col_name col_name
mysql>alter table pet change weight wei;
alter table tbl_name rename new_tbl
mysql>alter table pet rename animal;
mysql> ALTER TABLE user
-> MODIFY COLUMN pwd VARCHAR NOT NULL DEFAULT ‘666666';
mysql> ALTER TABLE user
-> ALTER COLUMN pwd varchar not null SETDEFAULT 5;
CREATETABLE IF NOT EXISTS dictionary ( id int(10) unsigned NOT NULLAUTO_INCREMENT, word varchar(100) NOT NULL, mean varchar(300) NOT NULL, PRIMARY KEY (`id`) );
mysql>DELIMITER $$
mysql>DROP PROCEDURE IF EXISTS SampleProc$$
Query OK, 0rows affected, 1 warning (0.01 sec)
CREATEPROCEDURE SampleProc()
BEGIN
DECLARE xINT;
SET x = 1;
WHILEx <= 110000 DO
insert intodictionary (word, mean) values(concat('a',x),concat('a means',x));
SET x = x + 1;
END WHILE;
END
mysql> DELIMITER ;
mysql>call SampleProc();
mysql> flush status;
Query OK, 0 rows affected (0.00 sec)
mysql> alter table dictionary
->modify column mean varchar(20) NOT null default 'DEFAULT1';
Query OK, 110002 rows affected (3.07 sec)
Records: 110002 Duplicates: 0 Warnings: 0
mysql> SHOW STATUS WHERE Variable_name LIKE'Handler%'
->OR Variable_name LIKE 'Created%';
+----------------------------+--------+
| Variable_name | Value |
+----------------------------+--------+
| Handler_read_rnd_next | 110003 |
| Handler_rollback | 0 |
| Handler_savepoint | 0 |
| Handler_savepoint_rollback | 0 |
| Handler_update | 0 |
| Handler_write | 110002 |
+----------------------------+--------+
mysql> flush status;
mysql> alter table dictionary
-> alter column mean set default'DEFAULT2';
Query OK, 0 rowsaffected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> SHOW STATUSWHERE Variable_name LIKE 'Handler%'
-> OR Variable_name LIKE 'Created%';
+----------------------------+-------+
| Variable_name | Value |
+----------------------------+-------+
|Handler_read_rnd_next | 0 |
|Handler_savepoint_rollback | 0 |
| Handler_update | 0 |
| Handler_write | 0 |
mysql>create table dictionary_new like dictionary;
mysql> alter table dictionary_new
-> modify column mean varchar(30)default 'DEFAULR#';
mysql> flush table with read lock;
mysql> unlock tables;
mysql> insert into dictionary(word) values('Random');
mysql> select * from dictionarywhere word='Random';
+--------+--------+----------+ | id | word | mean | +--------+--------+----------+ | 110004 |Random | DEFAULR# | +--------+--------+----------+
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有