Create a new table using Jobs table
CREATE TABLE JOBS_Temp AS SELECT * FROM HR.JOBS
Table created.
Select information from the newly created table
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 |
Adding two new columns.
ALTER TABLE JOBS_Temp
ADD (DUMMY1 NUMBER(2), DUMMY2 NUMBER(2))
Table altered.
Insert values into the newly added columns.
INSERT INTO JOBS_Temp(JOB_ID, JOB_TITLE, DUMMY1, DUMMY2) VALUES ('D','DUMMY',10,20)
1 row(s) inserted.
Insert values into the newly added columns.
INSERT INTO JOBS_Temp(JOB_ID, JOB_TITLE, DUMMY1, DUMMY2) VALUES ('D','DUMMY',10,20)
1 row(s) inserted.
Displaying the row information for new columns
SELECT * FROM JOBS_TEMP WHERE JOB_ID = 'D'
JOB_ID | JOB_TITLE | MIN_SALARY | MAX_SALARY | DUMMY1 | DUMMY2 |
---|---|---|---|---|---|
D | DUMMY | - | - | 10 | 20 |
D | DUMMY | - | - | 10 | 20 |
Setting the newly added columns to Unused
ALTER TABLE JOBS_TEMP SET UNUSED (DUMMY1, DUMMY2)
Table altered.
Displaying the number of unused columns count
SELECT * FROM USER_UNUSED_COL_TABS WHERE TABLE_NAME='JOBS_TEMP'
TABLE_NAME | COUNT |
---|---|
JOBS_TEMP | 2 |
Display the table information
SELECT * FROM JOBS_TEMP WHERE MAX_SALARY > 10000
JOB_ID | JOB_TITLE | MIN_SALARY | MAX_SALARY |
---|---|---|---|
AD_PRES | President | 20080 | 40000 |
AD_VP | Administration Vice President | 15000 | 30000 |
FI_MGR | Finance Manager | 8200 | 16000 |
AC_MGR | Accounting Manager | 8200 | 16000 |
SA_MAN | Sales Manager | 10000 | 20080 |
SA_REP | Sales Representative | 6000 | 12008 |
PU_MAN | Purchasing Manager | 8000 | 15000 |
MK_MAN | Marketing Manager | 9000 | 15000 |
PR_REP | Public Relations Representative | 4500 | 10500 |
Drop the unused columns
ALTER TABLE JOBS_TEMP DROP UNUSED COLUMNS
Table altered.
Dispaly the table after dropping the unused columns
SELECT * FROM JOBS_TEMP
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 |
D | DUMMY | - | - |
D | DUMMY | - | - |