31.Oracle数据库SQL开发之 SQLPlus使用——自动生成SQL语句
使用SQL语句来生成其他SQL语句。
产生一些列DROP TABLE语句,如下:
store@PDB1> SELECT 'DROP TABLE ' || table_name ||';' from user_tables;
'DROPTABLE'||TABLE_NAME||';'
----------------------------------------------------------------------
DROP TABLECUSTOMERS;
DROP TABLEPRODUCT_TYPES;
DROP TABLEPRODUCTS;
DROP TABLEPURCHASES;
DROP TABLEEMPLOYEES;
DROP TABLESALARY_GRADES;
DROP TABLEPURCHASES_WITH_TIMESTAMP;
DROP TABLEPURCHASES_TIMESTAMP_WITH_TZ;
DROP TABLEPURCHASES_WITH_LOCAL_TZ;
DROP TABLECOUPONS;
DROP TABLEPROMOTIONS;
DROP TABLEORDER_STATUS;
DROP TABLEPRODUCT_CHANGES;
DROP TABLEMORE_PRODUCTS;
DROP TABLEMORE_EMPLOYEES;
DROP TABLEDIVISIONS;
DROP TABLEJOBS;
DROP TABLEEMPLOYEES2;
DROP TABLEALL_SALES;
DROP TABLEPRODUCT_PRICE_AUDIT;
DROP TABLEREG_EXPS;
DROP TABLEPIVOT_SALES_DATA;
DROP TABLEBINARY_TEST;
23 rows selected.
可以将SQL语句保存到一个文件中,供以后使用。
很高级的事情,其实做起来也是比较简单。复杂事情都是由简单事情组成的嘛。