Recipe 5.6. Using SQL to Generate SQL
select 'select count(*) from '||table_name||';' cnts
from user_tables;
CNTS
----------------------------------------
select count(*) from ANT;
select count(*) from BONUS;
select count(*) from DEMO1;
select count(*) from DEMO2;
select count(*) from DEPT;
select count(*) from DUMMY;
select count(*) from EMP;
select count(*) from EMP_SALES;
select count(*) from EMP_SCORE;
select count(*) from PROFESSOR;
select count(*) from T;
select count(*) from T1;
select count(*) from T2;
select count(*) from T3;
select count(*) from TEACH;
select count(*) from TEST;
select count(*) from TRX_LOG;
select count(*) from X;
/* disable foreign keys from all tables */
select 'alter table '||table_name||
' disable constraint '||constraint_name||';' cons
from user_constraints
where constraint_type = 'R';
CONS
------------------------------------------------
alter table ANT disable constraint ANT_FK;
alter table BONUS disable constraint BONUS_FK;
alter table DEMO1 disable constraint DEMO1_FK;
alter table DEMO2 disable constraint DEMO2_FK;
alter table DEPT disable constraint DEPT_FK;
alter table DUMMY disable constraint DUMMY_FK;
alter table EMP disable constraint EMP_FK;
alter table EMP_SALES disable constraint EMP_SALES_FK;
alter table EMP_SCORE disable constraint EMP_SCORE_FK;
alter table PROFESSOR disable constraint PROFESSOR_FK;
/* generate an insert script. from some columns in table EMP */
from user_tables;
CNTS
----------------------------------------
select count(*) from ANT;
select count(*) from BONUS;
select count(*) from DEMO1;
select count(*) from DEMO2;
select count(*) from DEPT;
select count(*) from DUMMY;
select count(*) from EMP;
select count(*) from EMP_SALES;
select count(*) from EMP_SCORE;
select count(*) from PROFESSOR;
select count(*) from T;
select count(*) from T1;
select count(*) from T2;
select count(*) from T3;
select count(*) from TEACH;
select count(*) from TEST;
select count(*) from TRX_LOG;
select count(*) from X;
/* disable foreign keys from all tables */
select 'alter table '||table_name||
' disable constraint '||constraint_name||';' cons
from user_constraints
where constraint_type = 'R';
CONS
------------------------------------------------
alter table ANT disable constraint ANT_FK;
alter table BONUS disable constraint BONUS_FK;
alter table DEMO1 disable constraint DEMO1_FK;
alter table DEMO2 disable constraint DEMO2_FK;
alter table DEPT disable constraint DEPT_FK;
alter table DUMMY disable constraint DUMMY_FK;
alter table EMP disable constraint EMP_FK;
alter table EMP_SALES disable constraint EMP_SALES_FK;
alter table EMP_SCORE disable constraint EMP_SCORE_FK;
alter table PROFESSOR disable constraint PROFESSOR_FK;
/* generate an insert script. from some columns in table EMP */
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23895263/viewspace-681084/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Using Excel to generate Inserts for SQL ServerExcelSQLServer
- sql之27 using sql*plusSQL
- sql之26 using sql*plusSQL
- SCRIPT TO GENERATE SQL*LOADER CONTROL FILESQL
- Script to generate AWR report from remote sql clientREMSQLclient
- EXPLAIN PLAN and SQL*PLUS AUTOTRACE may not generate actual plansAISQL
- Using XML Parser for PL/SQLXMLSQL
- Using SQL Script Get Information about ASMSQLORMASM
- 動態 SQL、EXECUTE IMMEDIATE、using、into、returningSQL
- 【SQL】Using Oracle's Parallel Execution FeaturesSQLOracleParallel
- How to Quickly Create a Copy of a Table using Transact-SQLUISQL
- Send Email with Attachments from PL/SQL using Java Stored ProceduresAISQLJava
- Running Workload Repository Reports Using SQL ScriptsSQL
- How to See Supplier Contact Information Using SQL in R12ORMSQL
- mysql point in time recovery using sql_thread SQL_Thread增量恢復binlog 要點MySqlthread
- java.sql.SQLException: Access denied for user ‘root‘@‘localhost‘ (using password: YES)JavaSQLExceptionlocalhost
- Guide to Database Migration from Microsoft SQL Server using MySQL WorkbenchGUIIDEDatabaseROSServerMySql
- 自動生成sqlldr 控制檔案的指令碼(Script To Generate SQL*Loader Control File)SQL指令碼
- SQL%FOUND,SQL%NOTFOUND,SQL%ROWCOUNTSQL
- Example of SQL Linux Windows Authentication configuration using Managed Service AccountsSQLLinuxWindows
- Paging Records Using SQL Server 2005 Database - ROW_NUMBER FunctionSQLServerDatabaseFunction
- 【SQL】Oracle SQL monitorSQLOracle
- SQL in ORACLE and SQL ServerSQLOracleServer
- Connect SQL Server from Linux Client using Windows Authentication and troubleshoot stepsSQLServerLinuxclientWindows
- Failed to run 'create login' or 'sp_addsrvrolemeber' in sql Linux using windows authentcationAIVRSQLLinuxWindows
- 【SQL】17 SQL 檢視(Views)、SQL Date 函式、SQL NULL 值、SQLView函式Null
- PLSQL Language Referenc-PL/SQL動態SQL-練習:在USING子句中未初始化的變數表示NULLSQL變數Null
- 5.編寫recipe
- SQL注射/SQL Injection漏洞SQL
- 【SQL】19 SQL函式SQL函式
- SQL&PL/SQL (轉)SQL
- SQL------SQL效能分析SQL
- 【SQL Profile】coe_xfr_sql_profile.sql內容SQL
- SQL Server 管理常用的SQL和T-SQLSQLServer
- T-SQL、Jet SQL、PL-SQL 的含義SQL
- 【SQL】13 SQL 別名、SQL 連線(JOIN)、SQL INNER JOIN 關鍵字、SQL LEFT JOIN 關鍵字、SQL RIGHT JOIN 關鍵字、SQL FULL OUTER JSQL
- 【SQL】10 SQL UPDATE 語句SQL
- 【SQL】11 SQL DELETE 語句SQLdelete