mysql表增加一列sql
MySQL stores given relation data in tables. While using tables we generally need to check and list existing tables. We can use different ways to list tables. In this tutorial we will learn how to use show tables
and Select table_name
in order to list and print table names.
MySQL将给定的关系数据存储在表中。 使用表时,我们通常需要检查并列出现有表。 我们可以使用不同的方式列出表。 在本教程中,我们将学习如何使用show tables
和Select table_name
表名来列出和打印表名。
连接MySQL Interactive Shell (Connect MySQL Interactive Shell)
We need to connect or run command in MySQL to list table names. We will connect to the interactive MySQL server to run given commands. We will use mysql
command to connect local or remote MySQL interactive shell.
我们需要在MySQL中连接或运行命令以列出表名。 我们将连接到交互式MySQL服务器以运行给定命令。 我们将使用mysql
命令连接本地或远程MySQL交互式外壳。
$ mysql -u root -p
选择数据库 (Select Database)
In order to run given SQL commands and queries we need to specify the database we want to work. We will use show databases
and use DATABASENAME
command.
为了运行给定SQL命令和查询,我们需要指定我们要工作的数据库。 我们将使用show databases
并use DATABASENAME
命令。
mysql> use mysql;
显示表格SQL查询(show tables SQL Query)
Now we will run or show tables
query in this example. We can also use SHOW TABLES
which is uppercase version and have same affect with lowercase version. Do not skip to add semicolon to the end of the command.
现在,在此示例中,我们将运行或show tables
查询。 我们还可以使用SHOW TABLES
,它是大写版本,与小写版本具有相同的影响。 不要跳过将分号添加到命令末尾的操作。
mysql> show tables;
使用“ Select table_name”查询显示MySQL Server的所有表(Show All Tables of MySQL Server with “Select table_name” Query)
We have another alternative to show tables
query. This will list all tables created in connected MySQL instance.
我们还有另一种show tables
查询的方法。 这将列出在连接MySQL实例中创建的所有表。
mysql> SELECT table_name FROM information_schema.tables;
使用“选择表名”查询显示给定数据库的表(Show Tables Of Given Database with “Select table_name” Query)
In this exmaple we will use Select table_name
query but we will filter for given database by using where
statement for table_name
column. We will only list database named mysql
in this example.
在此示例中,我们将使用Select table_name
查询,但将通过使用table_name
列的where
语句来过滤给定的数据库。 在此示例中,我们仅列出名为mysql
数据库。
mysql> SELECT table_name FROM information_schema.tables where table_schema='mysql';
翻译自: https://www.poftut.com/how-to-list-mysql-tables-with-show-tables-sql-query/
mysql表增加一列sql