Create a New Table
In this section you create a new table.
- Invoke SQL*Plus and connect as the SYSTEM user.
- Alter session to pluggable database container orclpdb.
# SQL> alter session set container=orclpdb; Session altered.
- Create a new table named
HR.REGIONS_HIST
. Use the following statement to create a table that has the same structure and content as theHR.REGIONS
table.SQL>create table hr.regions_hist as select * from hr.regions; Table created.
- Query the new
HR.REGIONS_HIST
table.SQL>select * from hr.regions_hist; REGION_ID REGION_NAME ---------- ------------------------- 1 Europe 2 Americas 3 Asia 4 Middle East and Africa
Drop a Table
In this section you drop your new HR.REGIONS_HIST
table.
- Execute the
DROP TABLE
command to drop the table.SQL>drop table hr.regions_hist; Table dropped.
- Query the
HR.REGIONS_HIST
table.SQL>select * from hr.regions_hist; select * from hr.regions_hist * ERROR at line 1: ORA-00942: table or view does not exist
Notice that you get an error because the table is dropped.
Recover the Dropped Table
In this section you recover the HR.REGIONS_HIST
table from the recycle bin.
- Execute the
FLASHBACK TABLE
command to recover the dropped table.SQL>flashback table hr.regions_hist to before drop; Flashback complete.
- Once again query the
HR.REGIONS_HIST
table to verify the data has been restored.SQL>select * from hr.regions_hist; REGION_ID REGION_NAME ---------- ------------------------- 1 Europe 2 Americas 3 Asia 4 Middle East and Africa
- Exit from SQL*Plus.
No comments:
Post a Comment