How to drop not null constraint that will work both in PostgreSql and HSQL?
I'm using: ALTER TABLE tablename ALTER COLUMN columnname DROP NOT NULL;
But it's not working in HSQL.
This column was created: columnname TEXT NOT NULL,
We can remove a NOT NULL constraint from a column of an existing table by using the ALTER TABLE statement.
To remove a NOT NULL constraint for a column in MySQL, you use the ALTER TABLE .... MODIFY command and restate the column definition, removing the NOT NULL attribute.
Removing a NOT NULL constraint is pretty easy, no matter the constraint name was provided by system or user, you can just declare the column as NULL at attribute-level to revert the constraint. SQL> alter table countries modify (region_id null); Table altered.
To remove the NOT NULL constraint, use the DROP NOT NULL clause along with ALTER TABLE ALTER COLUMN statement.
The current HSQLDB syntax is: ALTER TABLE tablename ALTER COLUMN columnname SET NULL
But the PostgreSQL syntax will be supported in HSQLDB version 2.3.4 release.
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