找出列的默认值(Oracle)

时间:2022-10-12 09:03:01

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,猜猜有一些表提供了这些信息吗?

3 个解决方案

#1


9  

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。

#2


3  

try the below query

尝试以下查询

Select * From USER_TAB_COLUMNS where TABLE_NAME ='Table Name'

#3


-1  

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'

#1


9  

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。

#2


3  

try the below query

尝试以下查询

Select * From USER_TAB_COLUMNS where TABLE_NAME ='Table Name'

#3


-1  

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'