SQL> ALTER TABLE CUSTOMERS MODIFY AGE INT DEFAULT 10;
Table altered.
SQL > ALTER TABLE CUSTOMERS ALTER COLUMN AGE DROP DEFAULT;
ERROR at line 2:
ORA - 01735 : invalid ALTER TABLE OPTION.
How to Remove Default Constraints in SQL? To remove an existing DEFAULT constraint on any column, you can use the ALTER TABLE statement along with the DROP keyword in SQL. ALTER TABLE is used because the table is being modified or altered, and DROP is used to remove the constraint from the column of the table.
How to drop a column's default value? The following commands fails: ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT. ALTER TABLE t1 MODIFY c1 DROP DEFAULT.
To drop a primary key from a table, use an ALTER TABLE clause with the name of the table (in our example, product ) followed by the clause DROP PRIMARY KEY . Since a table can have only one primary key, you don't need to specify the primary key column(s).
Your ALTER
statement is wrong and you cannot use two ALTER
commands in one statement. And we never drop default value instead we set it to NULL
.
If a column has a default value, then you can use the DEFAULT clause to change the default to NULL, but you cannot remove the default value completely. If a column has ever had a default value assigned to it, then the DATA_DEFAULT column of the USER_TAB_COLUMNS data dictionary view will always display either a default value or NULL.
ALTER TABLE
Use the following SQL command to drop the default.
ALTER TABLE constomers MODIFY age DEFAULT NULL;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With