How can I disable all table constrains in Oracle with a single command?
This can be either for a single table, a list of tables, or for all tables.
Sql – Disable all table constraints in Oracle
oraclesql
Related Question
- Sql – Add a column with a default value to an existing table in SQL Server
- Sql – How to concatenate text from multiple rows into a single text string in SQL Server
- Sql – Get list of all tables in Oracle
- Sql – How to limit the number of rows returned by an Oracle query after ordering
- Sql – Insert results of a stored procedure into a temporary table
- Sql – Finding duplicate values in a SQL table
- Mysql – How to import an SQL file using the command line in MySQL
Best Solution
It is better to avoid writing out temporary spool files. Use a PL/SQL block. You can run this from SQL*Plus or put this thing into a package or procedure. The join to USER_TABLES is there to avoid view constraints.
It's unlikely that you really want to disable all constraints (including NOT NULL, primary keys, etc). You should think about putting constraint_type in the WHERE clause.
Enabling the constraints again is a bit tricker - you need to enable primary key constraints before you can reference them in a foreign key constraint. This can be done using an ORDER BY on constraint_type. 'P' = primary key, 'R' = foreign key.