1. Create an employee table with 5 columns including primary and foreign keys, unique constraints, and column checks.
2. Modify an existing employee table by adding a salary column, increasing the size of the ename column, and renaming the table.
3. Create a view to display only the employee names from the accounting department.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
37 views
SQL Assignments 1
1. Create an employee table with 5 columns including primary and foreign keys, unique constraints, and column checks.
2. Modify an existing employee table by adding a salary column, increasing the size of the ename column, and renaming the table.
3. Create a view to display only the employee names from the accounting department.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
Ass|gnments 1
Q1: Create an employee table that contains Iive columns:
Such as Employee Id, last name, First name, Phone number and Department number with the Iollowing constraints. 1. %he last name and Iirst name should be not null. 2. Make a check constraint to check the department number is between 9 and 100. 3. Make a primary constraint on the employee ID column. 4. Make a Ioreign key on the department number column. 5. Use the "delete " to delete all records. 6. Use the "phone number" as a unique key.
Q2: Create an employee table that contains Iive columns: Such as Employee Id, last name, First name, Phone number and Department number
1. Add a salary column to the employee table.
2. ModiIy the "ename" column size Irom varchar10 to varchar15.
3. Rename the "employee" table to the "iselIemployee" table.
4. Create a view to display the employee names oI the 'Accounting department only.
Q: Copy the 'EMP table to another table and name the new table "employee." In the new employee table use the employee name, job, commission and department number. A: SQL > CREATE TABLE employee AS SELECT ename, job, comm, deptno FROM emp;
Q: Add a salary column to the employee table. A: SQL > ALTER TABLE employee ADD (salary NUMBER(8,2));
Q: ModiIy the "ename" column size Irom varchar10 to varchar15. A: SQL > ALTER TABLE employee MODIFY (ename VARCHAR2(15));
Q: Rename the "employee" table to the "iselIemployee" table. A: SQL > RENAME employee TO iself_employee;
Q: Create a view to display the employee names oI the 'Accounting department only. A: SQL > CREATE VIEW employee_name AS SELECT ename FROM iself_employee WHERE deptno 10;