Sunday, 11 November 2018

ORA-00959: tablespace does not exist but I can see it in select

 

So, I am connected as SYSDBA to Oracle and trying to run this command:
 create user C##demo identified by demopassword;
That ends with User created.
Then I run:
alter user C##demo default tablespace PAVEL_DATA temporary tablespace PAVEL_TEMP;
Which ends in error:
ORA-00959: tablespace 'PAVEL_DATA' does not exist
But if I run this command:
SELECT TABLESPACE_NAME, STATUS, CONTENTS
FROM USER_TABLESPACES;
I can see the tablespaces:
  TABLESPACE_NAME          STATUS    CONTENTS
------------------------------ --------- ---------
SYSTEM                 ONLINE    PERMANENT
SYSAUX                 ONLINE    PERMANENT
TEMP                   ONLINE    TEMPORARY
USERS                  ONLINE    PERMANENT
UNDOTBS2               ONLINE    UNDO
PAVEL_DATA             ONLINE    PERMANENT
PAVEL_TEMP             ONLINE    TEMPORARY
So, why am I getting the error tablespace does not exist when it is created?
EDIT
Continued according the comments, this is what I see when I run select tablespace_name, con_id from cdb_tablespaces :
TABLESPACE_NAME            CON_ID
------------------------------ ----------
PAVEL_DATA              1
PAVEL_TEMP              1
SYSTEM                  4
SYSAUX                  4
TEMP                    4
USERS                   4

TABLESPACE_NAME            CON_ID
------------------------------ ----------
SYSTEM                  3
SYSAUX                  3
TEMP                    3
USERS                   3
EXAMPLE                 3    
PAVEL_TEMP              3
PAVEL_DATA              3
So, both tablespaces are created in DB$ROOT (id=1) and in pluggable datavase (id>2). But still, when connected to the pluggable database, I am getting the same error. It must be something stupid, but I am blind now...
 
 
 
Demonstration
 
SQL> create user c##_sales_hr identified by password default tablespace tbs_sales;
create user c##_sales_hr identified by password default tablespace tbs_sales
*
ERROR at line 1:
ORA-65048: error encountered when processing the current DDL statement in
pluggable database ORAPDB1
ORA-00959: tablespace 'TBS_SALES' does not exist


SQL> select tablespace_name, con_id from cdb_tablespaces;

TABLESPACE_NAME                CON_ID
------------------------------ ----------
SYSTEM                         1
SYSAUX                         1
UNDOTBS1                       1
TEMP                           1
USERS                          1
TBS_SALES                      1
SYSTEM                         4
SYSAUX                         4
TEMP                           4
ORAPDB1_TBS1                   4
MGMT_ECM_DEPOT_TS              4

11 rows selected.

SQL> alter session set container=orapdb1;

Session altered.

SQL> create tablespace tbs_sales datafile '+DATA' size 50M;

Tablespace created.

SQL> conn / as sysdba
Connected.
SQL> create user c##_sales_hr identified by password default tablespace tbs_sales;

User created.
 

 

Thursday, 11 January 2018

How to list the most biggest directory on AIX

du command - To list the most biggest directory

To list the five most biggest directory, you have to perform the command below:
du -sk ./* | sort -rn | head -5
Output:
$ du -sk ./* | sort -rn | head -5
27921556  ./dir100d
1920392 ./dir200d
14036   ./sqllib
8       ./dir300d
5       ./dir400d

Explaining the command above:
  • The du command displays the number of blocks used for files. If the File parameter specified is actually a directory, all files within the directory are reported on. If no File parameter is provided, the du command uses the files in the current directory.
  • ./* - This is the location where the du command will be display the number of
  •  blocks used for files inside the ./* directory
  •  Specifying the -s flag reports the total blocks for all specified files or all files in a directory.
  •  Specifying the -k flag shows the size of blocks in Kilobytes

sort

  • The sort command sorts lines in the files specified by the File  parameter and writes the result to standard output.
  •  -r     Reverses the order of the specified sort.
  •  -n   Sorts numeric fields by arithmetic value.
     
head
  • The head command writes to standard output a specified number of lines or bytes of each of the specified files, or of the standard input. If no flag is specified with the head command, the first 10 lines are displayed by defa