0% found this document useful (0 votes)
3 views2 pages

Script

The document contains a series of SQL queries for managing employee and student data in a database. It includes commands to display employee details, filter employees by department and name characteristics, and create and alter student tables with constraints. Additionally, it demonstrates inserting and deleting records from the student table.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Script

The document contains a series of SQL queries for managing employee and student data in a database. It includes commands to display employee details, filter employees by department and name characteristics, and create and alter student tables with constraints. Additionally, it demonstrates inserting and deleting records from the student table.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

SELECT * FROM emp;

1: Display the details OF ALL employee


SELECT* FROM emp;

2: Display the emp name AND annual salary OF ALL employee

SELECT ename, sal*12 AS "annual sal" FROM emp;

3:display the employees who ARE working IN dept 10

SELECT ename FROM emp WHERE deptno=10;

4: SELECT the employees whose name IS exact 5 charector IN LENGTH

SELECT ename FROM emp WHERE length(ename)=5;

5: SELECT sysdate FROM dual

6: display employee names whose name ends WITH k

SELECT ename FROM emp WHERE ename LIKE '%K';

7: display employee names whose 2nd CHARACTER IS D

SELECT ename FROM emp WHERE ename LIKE '_D%';

8: display employee names whose salary IS odd value

SELECT ename,sal FROM emp WHERE

SELECT * FROM emp;

king - KP
Blake - BM

SELECT ename, job FROM emp

ALTER TABLE TABLE_A ADD column_b number(5);

1: STudent
A:Student id(PRIMARY key)
B: Student name (NOT null)

CREATE TABLE Student


(
student_id number(5) PRIMARY KEY,
student_name varchar2(30) NOT NULL
);

ALTER TABLE student enable CONSTRAINT SYS_C007061 ;

DELETE student WHERE student_id=2;

SELECT constraint_name, constraint_type, table_name


FROM user_constraints
WHERE upper(table_name)='STUDENT';

CREATE TABLE student1


(student_id NUMBER(5)
CONSTRAINT student1_studentid_pk PRIMARY KEY,
student_name varchar2(30)
CONSTRAINT student1_studentname_nn NOT NULL
);

ALTER TABLE student1 disable CONSTRAINT student1_studentname_nn;

INSERT INTO student VALUES (2, null);

SELECT * FROM student;

You might also like