Useful shortcuts for vi editor

Showing posts with label tablespace. Show all posts
Showing posts with label tablespace. Show all posts

Wednesday, 11 April 2018

ORA-02449 solution

Preparation
SQL>
CREATE TABLESPACE EXAMPLE_TS DATAFILE
  'C:\ORACLEXE_XE\APP\ORACLE\ORADATA\XE\example_01.dbf' SIZE 512K REUSE
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;

SQL>
CREATE TABLESPACE EXAMPLE_TS_2 DATAFILE
  'C:\ORACLEXE_XE\APP\ORACLE\ORADATA\XE\example_02.dbf' SIZE 512K REUSE
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;

SQL>
CREATE TABLE T_EXAMPLE (ID NUMBER)
TABLESPACE EXAMPLE_TS;

SQL>
CREATE TABLE T_EXAMPLE_CHILD (ID NUMBER, FID NUMBER)
TABLESPACE EXAMPLE_TS_2;

SQL>
ALTER TABLE T_EXAMPLE
ADD CONSTRAINT ID_EXAMPLE_PK
PRIMARY KEY (ID);

SQL>
ALTER TABLE T_EXAMPLE_CHILD
ADD CONSTRAINT FID_EXAMPLE_FK
FOREIGN KEY (FID)
REFERENCES T_EXAMPLE (ID);

Action
SQL>
DROP TABLESPACE EXAMPLE_TS;

Error
ORA-01549: tablespace not empty, use INCLUDING CONTENTS option

Next Action
SQL>
DROP TABLESPACE EXAMPLE_TS INCLUDING CONTENTS AND DATAFILES;

Next Error
SQL>
ORA-02449: unique/primary keys in table referenced by foreign keys

Solid Solution
SQL>
DROP TABLESPACE EXAMPLE_TS INCLUDING CONTENTS AND DATAFILES CASCADE CONSTRAINTS;

ORA-01549 solution

Preparation
SQL>
CREATE TABLESPACE EXAMPLE_TS DATAFILE
  'C:\ORACLE_XE\APP\ORACLE\ORADATA\XE\example_01.dbf' SIZE 512K REUSE
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;

SQL>
CREATE TABLE T_EXAMPLE (ID NUMBER)
TABLESPACE EXAMPLE_TS;

Action
SQL>
DROP TABLESPACE EXAMPLE_TS;

Error
ORA-01549: tablespace not empty, use INCLUDING CONTENTS option

Solution
SQL>
DROP TABLESPACE EXAMPLE_TS INCLUDING CONTENTS AND DATAFILES;

Friday, 16 March 2018

ORA-00959 solution

Action
SQL> 
CREATE TABLE HR.EXAMPLE(ABC char(1));

Error
ORA-00959: tablespace '_$deleted$40$0' does not exist

Reason
Defined default tablespace is not available any more for HR user.

Solution
SQL>
ALTER USER HR DEFAULT TABLESPACE NEW_USERS;