您的位置:首页 > 数据库 > MySQL

mysql常用命令

2016-01-23 19:21 666 查看
建表和建数据库与sql中一样,

增删改查与sql也一样

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| db_1 |

| db_11 |

| db_2 |

| db_3 |

| db_6 |

| db_7 |

| db_8 |

| db_9 |

| mysql |

| performance_schema |

| sakila |

| test |

| world |

+--------------------+

14 rows in set (0.00 sec)



mysql> use db_11;

Database changed

mysql> show tables;

+-----------------+

| Tables_in_db_11 |

+-----------------+

| address |

| person |

+-----------------+

2 rows in set (0.00 sec)

mysql>

mysql> show table status \G;

*************************** 1. row ***************************

Name: address

Engine: InnoDB

Version: 10

Row_format: Compact

Rows: 0

Avg_row_length: 0

Data_length: 16384

Max_data_length: 0

Index_length: 0

Data_free: 0

Auto_increment: NULL

Create_time: 2016-01-23 15:28:17

Update_time: NULL

Check_time: NULL

Collation: utf8_general_ci

Checksum: NULL

Create_options:

Comment:

*************************** 2. row ***************************

Name: person

Engine: InnoDB

Version: 10

Row_format: Compact

Rows: 0

Avg_row_length: 0

Data_length: 16384

Max_data_length: 0

Index_length: 0

Data_free: 0

Auto_increment: NULL

Create_time: 2016-01-23 15:24:59

Update_time: NULL

Check_time: NULL

Collation: utf8_general_ci

Checksum: NULL

Create_options:

Comment:

2 rows in set (0.00 sec)

ERROR:

No query specified

mysql> show columns from person;

+-------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+-------+-------------+------+-----+---------+-------+

| id | int(11) | YES | | NULL | |

| name | varchar(20) | YES | | NULL | |

+-------+-------------+------+-----+---------+-------+

2 rows in set (0.01 sec)

mysql>

mysql> show procedure status \G;

*************************** 1. row ***************************

Db: sakila

Name: film_in_stock

Type: PROCEDURE

Definer: root@localhost

Modified: 2015-08-17 19:25:35

Created: 2015-08-17 19:25:35

Security_type: DEFINER

Comment:

character_set_client: utf8

collation_connection: utf8_general_ci

Database Collation: utf8_general_ci

*************************** 2. row ***************************

Db: sakila

Name: film_not_in_stock

Type: PROCEDURE

Definer: root@localhost

Modified: 2015-08-17 19:25:35

Created: 2015-08-17 19:25:35

Security_type: DEFINER

Comment:

character_set_client: utf8

collation_connection: utf8_general_ci

Database Collation: utf8_general_ci

*************************** 3. row ***************************

Db: sakila

Name: rewards_report

Type: PROCEDURE

Definer: root@localhost

Modified: 2015-08-17 19:25:35

Created: 2015-08-17 19:25:35

Security_type: DEFINER

Comment: Provides a customizable report on best customers

character_set_client: utf8

collation_connection: utf8_general_ci

Database Collation: utf8_general_ci

3 rows in set (0.01 sec)



ERROR:

No query specified



mysql> show columns from address;

+-------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+-------+-------------+------+-----+---------+-------+

| id | int(11) | YES | | NULL | |

| road | varchar(20) | YES | | NULL | |

+-------+-------------+------+-----+---------+-------+

2 rows in set (0.01 sec)





mysql> show table status like 'address' \G;

*************************** 1. row ***************************

Name: address

Engine: InnoDB

Version: 10

Row_format: Compact

Rows: 0

Avg_row_length: 0

Data_length: 16384

Max_data_length: 0

Index_length: 0

Data_free: 0

Auto_increment: NULL

Create_time: 2016-01-23 15:28:17

Update_time: NULL

Check_time: NULL

Collation: utf8_general_ci

Checksum: NULL

Create_options:

Comment:

1 row in set (0.00 sec)



ERROR:

No query specified



mysql>

mysql> select database(); //////查看当前使用的是哪个数据库

+------------+

| database() |

+------------+

| db_11 |

+------------+

1 row in set (0.04 sec)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: