MYSQL: Common SQL statements

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.