Display the Jobs table
SELECT * FROM HR.JOBS
JOB_ID | JOB_TITLE | MIN_SALARY | MAX_SALARY | AD_PRES | President | 20080 | 40000 | AD_VP | Administration Vice President | 15000 | 30000 | AD_ASST | Administration Assistant | 3000 | 6000 | FI_MGR | Finance Manager | 8200 | 16000 | FI_ACCOUNT | Accountant | 4200 | 9000 | AC_MGR | Accounting Manager | 8200 | 16000 | AC_ACCOUNT | Public Accountant | 4200 | 9000 | SA_MAN | Sales Manager | 10000 | 20080 | SA_REP | Sales Representative | 6000 | 12008 | PU_MAN | Purchasing Manager | 8000 | 15000 | PU_CLERK | Purchasing Clerk | 2500 | 5500 | ST_MAN | Stock Manager | 5500 | 8500 | ST_CLERK | Stock Clerk | 2008 | 5000 | SH_CLERK | Shipping Clerk | 2500 | 5500 | IT_PROG | Programmer | 4000 | 10000 | MK_MAN | Marketing Manager | 9000 | 15000 | MK_REP | Marketing Representative | 4000 | 9000 | HR_REP | Human Resources Representative | 4000 | 9000 | PR_REP | Public Relations Representative | 4500 | 10500 |
---|
Create a new table using Jobs table
CREATE TABLE JOBS_Temp AS SELECT * FROM HR.JOBS
Table created.
Displaying the information in the newly created table
SELECT * FROM JOBS_Temp WHERE MAX_SALARY > 30000
JOB_ID | JOB_TITLE | MIN_SALARY | MAX_SALARY | AD_PRES | President | 20080 | 40000 |
---|
Modifying an existing column definition in the new table
ALTER TABLE JOBS_Temp MODIFY(JOB_TITLE VARCHAR2(100))
Table altered.
Adding new columns into the new table
ALTER TABLE JOBS_Temp
ADD (BONUS NUMBER (7,2), COMM NUMBER (5,2), DUMMY NUMBER(2))
Table altered.
Displaying the newly added columns from the table
SELECT JOB_ID, BONUS, COMM, DUMMY FROM JOBS_Temp WHERE MAX_SALARY > 20000
JOB_ID | BONUS | COMM | DUMMY | AD_PRES | - | - | - | AD_VP | - | - | - | SA_MAN | - | - | - |
---|
Renaming a column using alter table
ALTER TABLE JOBS_Temp
RENAME COLUMN COMM TO COMMISSION
Table altered.
Displaying the modified column
SELECT JOB_ID, COMMISSION FROM JOBS_Temp WHERE MAX_SALARY > 20000
JOB_ID | COMMISSION | AD_PRES | - | AD_VP | - | SA_MAN | - |
---|
Dropping a column using alter table
ALTER TABLE JOBS_Temp DROP COLUMN DUMMY
Table altered.
Dropping multiple columns using alter table
ALTER TABLE JOBS_Temp DROP (BONUS, COMMISSION)
Table altered.
Display the table information after dropping the columns
SELECT * FROM JOBS_Temp WHERE MAX_SALARY > 20000
JOB_ID | JOB_TITLE | MIN_SALARY | MAX_SALARY | AD_PRES | President | 20080 | 40000 | AD_VP | Administration Vice President | 15000 | 30000 | SA_MAN | Sales Manager | 10000 | 20080 |
---|