gpt4 book ai didi

sql - 无法删除 Oracle 中的默认约束

转载 作者:行者123 更新时间:2023-12-01 09:49:44 25 4
gpt4 key购买 nike

SQL> ALTER TABLE CUSTOMERS MODIFY AGE INT DEFAULT 10;

表变了。
SQL > ALTER TABLE CUSTOMERS ALTER COLUMN AGE DROP DEFAULT;

ERROR at line 2:
ORA - 01735 : invalid ALTER TABLE OPTION.

最佳答案

您的 ALTER声明是错误的,您不能使用两个 ALTER命令在一个语句中。我们从不删除默认值,而是将其设置为 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

使用以下 SQL 命令删除默认值。
ALTER TABLE constomers MODIFY age DEFAULT NULL;

关于sql - 无法删除 Oracle 中的默认约束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40481708/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com