Hi everyone,
I've been trying different commands that check inputs that will be entered into the tables I've got. I want to check that Amount/Ename columns can not be NULL.
What's <> do in SQL?
// first command
ALTER TABLE Emp ADD CONSTRAINT CK_AMOUNT CHECK ( AMOUNT NOT NULL);
// second command
ALTER TABLE Emp ADD CONSTRAINT CK_AMOUNT CHECK ( AMOUNT != NULL);
They accept null values and the default value is 0
//first command
ALTER TABLE Emp ADD CONSTRAINT CK_ENAME CHECK ( Ename NOT NULL);
// second command
ALTER TABLE Emp ADD CONSTRAINT CK_ENAME CHECK ( Ename != NULL);
I also want my tables to accept specific values, for example, payment method has to be one of these options such as master card, visa or cash.
ALTER TABLE Emp ADD CONSTRAINT CK_Pay CHECK ( Pay="master card" OR "visa" OR "cash");
Thanks for the help..