1. Show CREATE TABLE
Mysql> Show create TABLE T \g
1. Row ***************************
Table:t
Create table:create Table ' t ' (
' A ' int (ten) unsigned DEFAULT NULL,
' B ' int (ten) unsigned DEFAULT NULL
) Engine=innodb DEFAULT charset=latin1
1 row in Set (0.00 sec)
2. Modify column: ALTER TABLE [TABLE_NAME] Change column [Original_column_name] [new_column_name] [data_type]:
Mysql> ALTER TABLE t change column A a int (4) unsigned zerofill;
Query OK, 0 rows affected (0.14 sec)
records:0 duplicates:0 warnings:0
Zerofill: Auto Fill 0 to specified width,
Mysql> select * from T;
+------+------+
| A | B |
+------+------+
| 0006 | 2 |
| 0008 | 5 |
| 0009 | 4 |
+------+------+
3 Rows in Set (0.00 sec)
This is only a display effect, the MySQL background store does not change
Mysql> Select a, Hex (a) from T;
+------+--------+
| A | Hex (a) |
+------+--------+
| 0006 | 6 |
| 0008 | 8 |
| 0009 | 9 |
+------+--------+
3 rows in Set (0.15 sec)
3. SELECT @ @global. sql_mode, select @ @session. sql_mode
Mysql> SELECT @ @global. sql_mode;
+--------------------------------------------+
| @ @global. Sql_mode |
+--------------------------------------------+
| strict_trans_tables,no_engine_substitution |
+--------------------------------------------+
1 row in Set (0.00 sec)
Mysql> SELECT @ @session. sql_mode;
+--------------------------------------------+
| @ @session. Sql_mode |
+--------------------------------------------+
| strict_trans_tables,no_engine_substitution |
+--------------------------------------------+
1 row in Set (0.00 sec)
Mysql>
MYSQL: Common SQL statements