我需要知道是否可以知道Column是“Required”还是“Nullable”。我找不到任何关于此的信息。是否有任何存储过程让我知道该列是否为必填字段?
答案 0 :(得分:3)
<强>的Oracle 强>
SELECT nullable
FROM user_tab_columns
WHERE table_name = 'TableName'
AND column_name = 'ColumnName';
<强> SQL-SERVER 强>
SELECT is_nullable
FROM sys.columns
WHERE object_id = object_id('TableName')
AND name = 'ColumnName';
<强>的MySQL 强>
SELECT IS_NULLABLE
FROM information_schema.columns
WHERE TABLE_NAME = 'TableName'
AND COLUMN_NAME = 'ColumnName';