In Oracle, you can specify a default value for a table column. In this way, when you insert data, if the column does not appear in the insert statement, the default value is assigned to it.
In Oracle, you can specify a default value for a table column. In this way, when you insert data, if the column does not appear in the insert statement, the default value is assigned to it.
In Oracle, you can specify a default value for a table column, so that when you insert data, if the column does not appear in the insert statement, the default value is assigned to it. note that this column does not appear in the insert statement, rather than when the column value is null. see the following table:
Create table test (id number (10), name varchar2 (20) default 'name ')
When the following SQL statement is used to insert rows, the default value is assigned to the name column.
Insert into test (id) values (1)
Query Result: select * from test
IDNAME
1 name
When the following SQL statement is used to insert rows, the default value is not assigned to the name column.
Insert into test values (2, null)
The query result shows that the name value of the row with ID 2 is null: select * from test
IDNAME
1 name
2
Select * from test where name is null can query the row with ID 2.
Similarly, when using JDBC in JAVA code and some ORM frameworks to insert data, you also need to pay attention to the same problem.
In the row inserted by the code above, the name column will not be assigned as the default value, and the value of #1 will be changed to sta. setString (2, ""). Similarly, the inserted value is null ).
For more information about Oracle, see the Oracle topic page? Tid = 12
,