SQL 用SQL显示表的结构
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7356338/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Show the structure of the table in SQL
提问by user770022
Can someone explain things a little better to me? How do I show the structure of a table?
I run the select * from table
; and of course it displays all that's in the table. But, I am being asked to show the structure of the table. What does that mean, and what is the command?
有人可以向我解释一下吗?如何显示表的结构?我运行select * from table
; 当然,它会显示表格中的所有内容。但是,我被要求显示表格的结构。这是什么意思,命令是什么?
Here's my table below.
这是我的下表。
SQL> select * from dept;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL>
回答by Michael Berkowski
To list columns and data types, I typically use
要列出列和数据类型,我通常使用
SELECT COLUMN_NAME, DATA_TYPE FROM ALL_TAB_COLUMNS WHERE TABLE_NAME='your_table_name';
It's been a while since I've worked with Oracle though. ALL_TAB_COLUMNS
might actually be ALL_TAB_COLS
.
不过,我已经有一段时间没有与 Oracle 合作了。 ALL_TAB_COLUMNS
可能实际上是ALL_TAB_COLS
。
If you need to display the full CREATE TABLE
statement, see How to get Oracle create table statement in SQL*Plus
如果您需要显示完整的CREATE TABLE
语句,请参阅如何在 SQL*Plus 中获取 Oracle create table 语句
回答by sribin
Try this out: describe table_name
试试这个: describe table_name