You are on page 1of 8

EX:NO:8 MANIPULATION OF DATA

DATE:
AIM:
To perform the concept manipulation of data and to describe different objects in sql.

PROCEDURE:
● To perform manipulating operations like inserting, updating and deleting rows into a
table.
● To perform table creation.
● To create views and other objects.
● Describe working of schema objects.

QUERIES:

1. Create the MY_EMPLOYEE table with these sample attributes.

QUERY: CREATE TABLE my_employee(id NUMBER(4) CONSTRAINT


my_employee_id_nn NOT NULL, last_name VARCHAR2(25),first_name
VARCHAR2(25), userid VARCHAR2(8), salary NUMBER(9,2));

OUTPUT:

2. Describe the structure of the MY_EMPLOYEE table to identify the column names.

QUERY: DESCRIBE my_employee

OUTPUT:

717821L
3. Create an INSERT statement to add the first row of data to the MY_EMPLOYEE
table from the following sample data. Do not list the columns in the INSERT clause.
QUERY: INSERT INTO my_employee VALUES (1, 'Patel', 'Ralph', 'rpatel', 895);

OUTPUT:

4. Populate the MY_EMPLOYEE table with the second row of sample data from the
preceding list.

QUERY: INSERT INTO my_employee (id, last_name, first_name,userid, salary)


VALUES (2,
'Dancs', 'Betty', 'bdancs', 860);

OUTPUT:

5. Confirm your addition to the table.

QUERY: SELECT * FROM my_employee;

OUTPUT:

6. Insert next data and confirm it.

QUERY: INSERT INTO my_employee (id, last_name, first_name,userid, salary)


VALUES (3,
'Biri' ,'Ben ','bbiri',1100);

INSERT INTO my_employee (id, last_name, first_name,userid, salary) VALUES (4,


'Newman','Chad','cnewman',750);

717821L
INSERT INTO my_employee (id, last_name, first_name,userid, salary) VALUES (5,
'Ropeburn','Audrey','aropebur',1550);

select * from my_employee


OUTPUT:

7. Make the data additions permanent.

QUERY: COMMIT;

OUTPUT:

8. Change the last name of employee 3 to Drexler.

QUERY: UPDATE my_employee SET last_name = 'Drexler' WHERE id = 3;

OUTPUT:

9. Change the salary to $1,000 for all employees who have a salary less than $900.

QUERY: UPDATE my_employee SET salary = 1000 WHERE salary < 900;

717821L
OUTPUT:

10. Verify your changes to the table.

QUERY: SELECT last_name, salary FROM my_employee;

OUTPUT:

11. Delete Betty Dancs from the MY_EMPLOYEE table.

QUERY: DELETE FROM MY_EMPLOYEE WHERE FIRST_NAME='Betty' AND


LAST_NAME='Dancs';

OUTPUT:

12. Confirm your changes to the table.

QUERY: SELECT * FROM my_employee;

OUTPUT:

717821L
13. Commit all pending changes.

QUERY: COMMIT;

OUTPUT:

14. Populate the table with the last row of sample data.

QUERY: INSERT INTO my_employee (id, last_name, first_name,userid, salary)


VALUES (6,
'Chris','Evans','echris',2550);

OUTPUT:

15. Confirm your addition to the table.

QUERY: SELECT * FROM my_employee;

OUTPUT:

717821L
16. Mark an intermediate point in the processing of the transaction.

QUERY: SAVEPOINT A;

17. Empty the entire table.

QUERY: DELETE FROM my_employee;

OUTPUT:

18. Confirm that the table is empty.

QUERY: SELECT * FROM my_employee;

OUTPUT:

19. Discard the most recent DELETE operation without discarding the earlier INSERT
operation.

QUERY: ROLLBACK TO A;

20. Confirm that the new row is still intact. QUERY: select * from my_employee

OUTPUT:

717821L
21. Make the data addition permanent.

QUERY: COMMIT;

OUTPUT:

22. Create the DEPT table based on the following table instance chart. Now confirm its
creation.

QUERY: CREATE TABLE dept (Id NUMBER(7),Name

VARCHAR2(25)); select * from dept;

OUTPUT:

23. Populate the DEPT table with data from the DEPARTMENTS table. Include only
columns that you need.

QUERY: INSERT INTO Dept values (1,'raj') SELECT id,name FROM dept;

24. Create the EMP table based on the following table instance chart. confirm table.

QUERY: CREATE TABLE Emp (Id NUMBER(7),First_name VARCHAR2(25),Last_name


VARCHAR2(25),dept_id NUMBER(7));

OUTPUT:

25. Create the EMPLOYEES2 table based on the structure of the EMPLOYEES
table.Include only the EMPLOYEE_ID, FIRST_NAME, LAST_NAME,
SALARY, and DEPARTMENT_ID columns. Name the columns in your new table
ID, FIRST_NAME,LAST_NAME, SALARY, and DEPT_ID, respectively.

QUERY: CREATE TABLE EMPLOYEE2 (FIRST_NAME VARCHAR2(25),


LAST_NAME VARCHAR2(25), SALARY NUMBER(9,2) ,DEPT_ID VARCHAR2(8))

SELECT first_name,last_name,salary,dept_id FROM employee2;

717821L
OUTPUT:

26. Drop the EMP table. QUERY: DROP TABLE Emp;

OUTPUT:

RESULT:

Thus the manipulation of data and to describe objects in sql has been executed and
verified successfully.

717821L

You might also like