1

What does the "Null" column mean in the results of DESCRIBE?

Ex:

decribe table1;

Name                 Null       Type
------------------  ----------  ---------------
Number                          Number(5)
Name                            Varchar2(25)
DeptNo              NotNull     Number(5)
Jeffrey Kemp
  • 59,135
  • 14
  • 106
  • 158
dimiky
  • 15
  • 4
  • 1
    The null column states whether that field is nullable or not - do you know what a NULL is? – RB. Mar 27 '13 at 08:45

3 Answers3

4

It tells you if NULL is allowed as value in this column or not.

If the describe statement returns no value for this column, NULL values are allowed, if it returns NotNull, NULL values are not allowed.

Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443
  • Thanks for your info. I'm writing a query using Select statement display to display the structure of the table. in that query I need to add the NULL column. can you tell me how to add. My Query is : select column_name as Name, nullable,data_type || '(' || data_length || ')' as Type from user_tab_columns where table_name='EMP'; here EMP table consist of Three Columns one is name varchar2(25), no number(5), Deptno number(5) unique; – dimiky Mar 27 '13 at 09:03
  • Try `"Null"` (including the quotes) as the column name. – Daniel Hilgarth Mar 27 '13 at 09:11
  • thanks. but it showing all the records as null but i need to display only Deptno as NotNULL.. – dimiky Mar 27 '13 at 09:15
  • 1
    If you're looking to replicated the describe command you can use this question @dimiky: http://stackoverflow.com/questions/9855209/how-can-i-describe-a-table-in-oracle-without-using-the-describe-command/9855458#9855458] – Ben Mar 27 '13 at 09:43
0

USER_TAB_COLUMNS.NULLABLE contains 'N' if a column is not allowed to be set to NULL, and 'Y' if the column may be set to NULL. If you want to model the behavior of DESCRIBE it looks like your statement should be something like:

select column_name as Name,
       CASE nullable WHEN 'N' THEN 'NotNull' WHEN 'Y' THEN NULL END AS NULLABLE,
       data_type || '(' || data_length || ')' as TYPE
  from user_tab_columns
  where table_name='EMP'

Share and enjoy.

0

Null value for column name

You can give a column name as 'null-able' or not nullable while creating new table.

CREATE TABLE table_name (col1 VARCHAR2(20) NULL,col2 VARCHAR2(35) NOT NULL)

If you try to insert NULL values for col2 you will get a error message[ORA-01400].

But we should remember that this is not like a key[primary,unique].

rcmuthu786
  • 130
  • 1
  • 6