什么查询在幕后描述 运行
What query does DESCRIBE run behind the scenes
是否有 DESCRIBE
运行 在幕后进行的查询?
例如:
DESCRIBE myTable
DESCRIBE myView
有什么我可以 运行 针对 informational_schema
到 运行 的查询,还是仅供内部使用?
我觉得DESCRIBE
不标准SQL。它在 MySQL 中提供是为了与同名的 Oracle 语句兼容。这里有一条评论:https://github.com/mysql/mysql-server/blob/8.0/sql/sql_yacc.yy#L13974-L13980
/* A Oracle compatible synonym for show */
describe_stmt:
describe_command table_ident opt_describe_column
SHOW COLUMNS
和 DESCRIBE <table>
最终都调用了同一个函数,build_show_columns_query()
,在此处实现:
https://github.com/mysql/mysql-server/blob/8.0/sql/dd/info_schema/show.cc#L612-L617
它基本上是针对 INFORMATION_SCHEMA.COLUMNS
的查询,对于一个特定的模式和 table,以及可选的其他 user-defined 条件,带有 select 的 WHERE
子句.您可以自己编写相同的查询。
SQL 的其他实现有不同的命令来提供类似的元数据:
- PostgreSQL 使用
\d <table>
客户端命令:https://www.educba.com/postgresql-describe-table/
- Microsoft SQL 服务器使用
exec sp_columns <table>
:https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-columns-transact-sql?view=sql-server-ver15
- SQL站点使用
pragma table_info(<table>)
:https://www.sqlitetutorial.net/sqlite-describe-table/
- Informix 使用
info columns for <table>
:https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-info-statement
如果您想知道任何其他品牌的等效项,可能您可以 google 搜索“describe table in ”。
是否有 DESCRIBE
运行 在幕后进行的查询?
例如:
DESCRIBE myTable
DESCRIBE myView
有什么我可以 运行 针对 informational_schema
到 运行 的查询,还是仅供内部使用?
我觉得DESCRIBE
不标准SQL。它在 MySQL 中提供是为了与同名的 Oracle 语句兼容。这里有一条评论:https://github.com/mysql/mysql-server/blob/8.0/sql/sql_yacc.yy#L13974-L13980
/* A Oracle compatible synonym for show */ describe_stmt: describe_command table_ident opt_describe_column
SHOW COLUMNS
和 DESCRIBE <table>
最终都调用了同一个函数,build_show_columns_query()
,在此处实现:
https://github.com/mysql/mysql-server/blob/8.0/sql/dd/info_schema/show.cc#L612-L617
它基本上是针对 INFORMATION_SCHEMA.COLUMNS
的查询,对于一个特定的模式和 table,以及可选的其他 user-defined 条件,带有 select 的 WHERE
子句.您可以自己编写相同的查询。
SQL 的其他实现有不同的命令来提供类似的元数据:
- PostgreSQL 使用
\d <table>
客户端命令:https://www.educba.com/postgresql-describe-table/ - Microsoft SQL 服务器使用
exec sp_columns <table>
:https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-columns-transact-sql?view=sql-server-ver15 - SQL站点使用
pragma table_info(<table>)
:https://www.sqlitetutorial.net/sqlite-describe-table/ - Informix 使用
info columns for <table>
:https://www.ibm.com/docs/en/informix-servers/14.10?topic=statements-info-statement
如果您想知道任何其他品牌的等效项,可能您可以 google 搜索“describe table in