DROP STAGE

Description

DROP STAGE drops a named internal or external data stage from the database. The data stage is a temporary storage area that loads data from a file into a database table or exports data from a database table to a file. Use the DROP STAGE command to remove stages of data that are no longer needed from the database, freeing storage space and avoiding additional storage charges.

Note

The cluster administrator (i.e., the root user) and account administrators can delete data stages.

Syntax

  1. -- Delete internal stage
  2. > DROP STAGE [IF EXISTS] {internal_stage_name};
  3. -- Delete external stage
  4. > DROP STAGE [IF EXISTS] {external_stage_name};

Examples

  1. CREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));
  2. INSERT INTO user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');
  3. -- Create internal data stage
  4. mysql> CREATE STAGE stage1 URL='/tmp' ENABLE = TRUE;
  5. -- Export data from the table to data stage
  6. mysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';
  7. -- You can see your exported table in your local directory
  8. -- delete stage1
  9. mysql> drop stage stage1;
  10. Query OK, 0 rows affected (0.01 sec)
  11. -- stage1 has been deleted; the data stage is not available
  12. mysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';
  13. ERROR 20101 (HY000): internal error: stage 'stage1' is not exists, please check