在表中显示属性 (Oracle)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5691985/
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
showing attributes in table (Oracle)
提问by SunyGirl
How can I write an SQL query to show all the attributes in the table which are not NULL?
如何编写 SQL 查询以显示表中非 NULL 的所有属性?
回答by Jeffrey Kemp
You can list all columns in a table which are defined as NOT NULL with a query like this:
您可以使用如下查询列出表中定义为 NOT NULL 的所有列:
select column_name
from USER_TAB_COLUMNS
where table_name = 'MYTABLE'
and nullable = 'N';
(If the table is not owned by the logged-in user, you can query ALL_TAB_COLUMNS instead.)
(如果该表不归登录用户所有,则可以改为查询 ALL_TAB_COLUMNS。)
回答by Tristan
You can't, because some records will have some attribute null, and some other records will have this attribute not null.
你不能,因为有些记录的某些属性为空,而其他一些记录的这个属性不为空。
If an attribute is always null, just drop the column.
如果属性始终为空,则只需删除该列。
回答by aiknr
You can use the describe command
您可以使用描述命令
DESC TABLENAME;