I am adding a column to my database table. It is a simple Char column with either a value of 'Y' or 'N'.
Is it possible to default the column to be 'N'? If so, how?
Current Script to add column:
ALTER TABLE PERSON
ADD IS_ACTIVE VARCHAR2(1);
I am adding a column to my database table. It is a simple Char column with either a value of 'Y' or 'N'.
Is it possible to default the column to be 'N'? If so, how?
Current Script to add column:
ALTER TABLE PERSON
ADD IS_ACTIVE VARCHAR2(1);
ALTER TABLE PERSON
ADD IS_ACTIVE VARCHAR2(1) DEFAULT 'N'
If you want, you can add a NOT NULL constraint:
ALTER TABLE PERSON
ADD IS_ACTIVE VARCHAR2(1) DEFAULT 'N' NOT NULL
According to the documentation:
ALTER TABLE person ADD is_active VARCHAR2(1) DEFAULT 'N';
you just need to add Default <your default value>
to it.
for example:
ALTER TABLE person ADD is_active VARCHAR2(20) DEFAULT 'N';
MySql version
While creating table
CREATE TABLE tblPERSON ( id INT NOT NULL , IS_ACTIVE CHAR NULL DEFAULT 'N' )
Altering
ALTER TABLE tblperson ADD IS_ACTIVE CHAR NULL DEFAULT 'N'