New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DDL syntax to change (not) nullable state of columns [CORE1180] #1606
Comments
Commented by: @paulvink I agree that this would be useful. Meanwhile, Pierre, it *can* be done with DDL. Cookbook is here: http://www.firebirdsql.org/manual/nullguide-alter-pop-tables.html#nullguide-make-column-non-nullable |
Commented by: Mirco Malaguti (mirmalag) Hi Pierre and Paul. Thank you Mirco |
Modified by: @pcisarWorkflow: jira [ 11714 ] => Firebird [ 15524 ] |
Modified by: @asfernandes |
Modified by: @asfernandesFix Version: 3.0 Initial [ 10301 ] assignee: Adriano dos Santos Fernandes [ asfernandes ] |
Modified by: @pavel-zotovQA Status: No test |
Commented by: PizzaProgram Ltd. (szakilaci) Please re-OPEN this case, because since Firebird 3.0 > this workaround does not work any more! We need a solution for this that works on ALL versions of FB the same way. (from 1.5- to 3.x) Tried everything, like: 3.] ... but no solution. Thank you, |
Commented by: @dyemanov There's no solution that would work the same way in all FB versions. You need to use either "update rdb$relation_fields" or "alter table", depending on FB version. |
Commented by: PizzaProgram Ltd. (szakilaci) "alter table.." is currently NO SOLUTION to 3.0, because you can not insert the constraint_name directly, without an intermediate API. (See my not-working No.2 example). Isn't it possible at least to make this format work on 3.x and than back-port to FB2.5: alter table <table_name> alter column <column_name> set DEFAULT NULL; Thanks ;) |
Commented by: PizzaProgram Ltd. (szakilaci) By the way, these pages needs to be upgraded to exclude FB3 from "solutions and Tips" until this issue has been solved: http://www.firebirdfaq.org/faq103/ |
Commented by: PizzaProgram Ltd. (szakilaci) Please reopen this ticket and increase priority. |
Commented by: @dyemanov You don't need to know the constraint name: |
Commented by: PizzaProgram Ltd. (szakilaci) It WORKS ! Thanks :) please add these lines to the manual + FAQ ! Firebird 3.0 up: ALTER TABLE <table_name> ALTER COLUMN <column_name> DROP NOT NULL; |
Commented by: @dyemanov It's documented in the release notes: The Null Guide wasn't updated for FB v3 yet. |
Modified by: @pavel-zotovstatus: Resolved [ 5 ] => Resolved [ 5 ] QA Status: No test => Covered by another test(s) Test Details: Several tests exist that covers this functionality. 2) See also tests for: |
Submitted by: Pierre Yager (pierrey)
Relate to CORE1684
Is duplicated by CORE2464
Is related to QA505
Votes: 4
I checked this old document related to IB6 :
http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_60_sqlref#RSf47768
So I'm not sure if this already exists but since I never found a way to achieve this using DDL SQL I suggest you add a way to alter the nullable/not nullable state of an EXISTING column.
Somewhat like :
ALTER TABLE [table_name]
ALTER COLUMN [column_name] [TO BE] [NOT] NULL[ABLE];
For now I have to create some "upgrade scripts" to create a temporary column, move existing data, drop old one and change the new one's name.
Some voodoo tools like IBExpert knows some magic SQL that do the trick.
Can't that be done the official way ?
Commits: edb4192 6479022 79caf4e 0faabd1 0145996 ed0e0da FirebirdSQL/fbt-repository@2bdba17 FirebirdSQL/fbt-repository@47a6da0
====== Test Details ======
Several tests exist that covers this functionality.
1) Tests that manipulates with NULL fields/domains and check results:
CORE1518 Adding a non-null restricted column to a populated table renders the table inconsistent
CORE4453 (Regression: NOT NULL constraint, declared in domain, does not work)
CORE4725 (Inconsistencies with ALTER DOMAIN and ALTER TABLE with DROP NOT NULL and PRIMARY KEYs)
CORE4733 (Command "Alter table <T> alter TYPE <C> <DOMAIN_WITH_NOT_NULL" does not verifies data in column <C> and makes incorrect assignments in <C> to ZERO / JULIAN_DATE / ASCII(0) for types INT, TIMESTAMP and VARCHAR)
2) See also tests for:
CORE0304, CORE3085 (alter domain set/drop not null);
CORE0907, CORE4466(alter table <T> alter column <C> set not null);
The text was updated successfully, but these errors were encountered: