Default varchar value : Column Default Value « Table « Oracle PL / SQL






Default varchar value

   
SQL>
SQL>
SQL> CREATE TABLE myTable (
  2     Name    VARCHAR(50) NOT NULL,
  3     PhoneNo VARCHAR(15) DEFAULT 'Unknown Phone' NOT NULL
  4  );

Table created.

SQL>
SQL> INSERT INTO myTable (Name, PhoneNo) VALUES ('Tom', '555 2323');

1 row created.

SQL> INSERT INTO myTable (Name) VALUES ('Tom');

1 row created.

SQL> INSERT INTO myTable (Name, PhoneNo) VALUES ('Tom', NULL);
INSERT INTO myTable (Name, PhoneNo) VALUES ('Tom', NULL)
                                                   *
ERROR at line 1:
ORA-01400: cannot insert NULL into ("JAVA2S"."MYTABLE"."PHONENO")


SQL>
SQL> DROP TABLE myTable;

Table dropped.

   
    
    
  








Related examples in the same category

1.Override the defaults by specifying a value for the columns
2.Create table with column having the default value
3.column with default as sysdate
4.Use rpad to fill default value to a column
5.null with default value column
6.Default char value
7.Use char function to build default column value