mysql表增加一列sql_如何使用“显示表​​” SQL查询列出MySQL表

mysql表增加一列sql

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 tablesSelect 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
Connect MySQL Interactive Shell
Connect MySQL Interactive Shell
连接MySQL Interactive Shell

选择数据库 (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 databasesuse DATABASENAME命令。

mysql> use mysql;
Select Database
Select Database
选择数据库

显示表格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;
show tables SQL Query
show tables SQL Query
显示表格SQL查询

使用“ 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 All Tables of MySQL Server with "Select table_name Query"
Show All Tables of MySQL Server with “Select table_name” Query
使用“ Select table_name”查询显示MySQL Server的所有表

使用“选择表名”查询显示给定数据库的表(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';
Show Tables Of Given Database with "Select table_name" Query
Show Tables Of Given Database with “Select table_name” Query
使用“选择表名”查询显示给定数据库的表
LEARN MORE  Php Tutorial
了解更多PHP教程

翻译自: https://www.poftut.com/how-to-list-mysql-tables-with-show-tables-sql-query/

mysql表增加一列sql

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值