Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DROP NOT NULL CONSTRAINT

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,

like image 989
kostepanych Avatar asked Mar 24 '16 12:03

kostepanych


People also ask

Can we drop NOT NULL constraint?

We can remove a NOT NULL constraint from a column of an existing table by using the ALTER TABLE statement.

How do I drop a NOT NULL constraint in MySQL?

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.

How do I drop NOT NULL constraint in SQL Plus?

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.

How do you drop a NOT NULL constraint from a column in Postgres?

To remove the NOT NULL constraint, use the DROP NOT NULL clause along with ALTER TABLE ALTER COLUMN statement.


1 Answers

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.

like image 197
fredt Avatar answered Sep 20 '22 16:09

fredt