SQL 找出列的默认值 (Oracle)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14478541/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 13:16:03  来源:igfitidea点击:

Find out the default value for a column (Oracle)

sqloracleselectdefault

提问by aLpenbog

I wonder if there is a way to find out the default value of some column with a simple select statement. Tried several things like:

我想知道是否有办法通过简单的 select 语句找出某些列的默认值。尝试了几件事,例如:

SELECT * FROM all_tab_columns WHERE table_name = 'tablename'

But I can't see the defaultvalues for the columns there. And no I do not want to use something like SQL Plus, I need a SELECT, guess there is some table providing that info?

但是我看不到那里列的默认值。不,我不想使用 SQL Plus 之类的东西,我需要一个 SELECT,猜猜有没有提供该信息的表?

回答by Bhuvan Upadhyay

Select TABLE_NAME, COLUMN_NAME, DATA_DEFAULT
from DBA_TAB_COLUMNS
where TABLE_NAME = 'TABLE_NAME';

Replace the Table_Name for which you want to see the default column data.

替换要查看其默认列数据的 Table_Name。

回答by Pandian

try the below query

试试下面的查询

Select * From USER_TAB_COLUMNS where TABLE_NAME ='Table Name'

回答by helenov

Default values are in DATA_DEFAULT column from ALL_TAB_COLUMNS:

默认值位于 ALL_TAB_COLUMNS 的 DATA_DEFAULT 列中:

SELECT TABLE_NAME, COLUMN_NAME, DATA_DEFAULT 
  FROM ALL_TAB_COLUMNS
 WHERE TABLE_NAME = 'tablename'