DATABASE (SQL)day 3) CHECK CONSTARAINT , KEY, DROP COLUMN(DELETE)
* CHECK CONSTRAINT *
CHECK CONSTARINT DIRECTRY APPLY TO PERTICULAR COLUMN.
QUERY:-
- create table emp(id int ,name varchar(50),salary INT ,CONSTRAINT sell CHECK(salary>1000));
- INSERT INTO emp VALUES (101,'MOHAN',2000);
- INSERT INTO emp VALUES (102,'SOHAM',500);
- SELECT * FROM emp;
*KEY*
* KEY IS USE TO MANAGING THE TABLE .
*THERE ARE SOMETYPES OF KEY
1)PRIMARY KEY :-NO BLANK ,NO REPEAT
2)UNIQUE KEY :-NO REPEAT ,BLANK POSSIBLE
3)FOREIGN KEY
*PRIMARY KEY*
Q)TYPES OF METHOD IS USED TO CREATING A KEY.
1)COLOUM LEVEL PRIMARY KEY:-1COLUNM
2)TABEL LEVEL PRIMARY KEY :-MORE THAN COLUNM
*-QUERY-*
CREATE TABLE stu2(roll INT PRIMARY KEY ,name VARCHAR (50));
INSERT INTO stu2 VALUES (201,'SONAM');
SELECT * FROM stu2;
*UNIQUE KEY*
CREATE TABLE stu3(roll INT UNIQUE,name VARCHAR(50));
INSERT INTO stu3 VALUES(301,'AJAY');
SELECT * FROM stu3;
*DROP COLUMN*
Q) HOW TO DELETE COLUMN
= ALTER COMMAND AND DROP COLUMN COMMAND.
QUERY:-
ALTER TABLE tablename DROP COLUMN columnname;
check constraint ,key,drop delete column |
Comments
Post a Comment