oracle 如何查看当前用户的表空间名称

如何查询当前用户的表空间名称?因为oracle建立索引,需要知道当前用户的表空间,查找了一下资料

 --查询语法--
 select default_tablespace from dba_users where username='登录用户'
   

如,我的登录用户是TMS21,那么查询语法是

 /* 查看用户所属的表空间 */
 select default_tablespace from dba_users where username='TMS21';

相关查询的用法,也顺便记录一下

1)查询当前用户表空间

 /* 查看用户所属的表空间 */
 select default_tablespace from dba_users where username='TMS21';

2)查询所有表空间

  /*查看所有的表空间 */
   -- 1 )方式1:dba_tablespaces --
   select * from dba_tablespaces;
    --2 )方式2:v$tablespace --
   select * from v$tablespace;   

3)查询用户下所有表

  /* 查看用户下面的所有的表 */ 
  -- 1 )方式1:user_tables --
   select * from user_tables;
   --2 )方式2: dba_tables --
   select * from dba_tables where owner='TMS21';

4)查询表空间下的用户

  /*查看表空间下有多少用户,tablespace_name表空间 的名字一定要大写 */
   select distinct s.owner from dba_segments s where s.tablespace_name ='TMS21';  

PS:因为我的表空间名称跟用户一样,所以4)中的表空间都是TMS21(以查询结果为主)

资料来源:https://blog.csdn.net/qq_26941173/article/details/77155421

平时多记记,到用时才能看看,记录你的进步,分享你的成果

如何查询当前用户的表空间名称?因为oracle建立索引,需要知道当前用户的表空间,查找了一下资料

 --查询语法--
 select default_tablespace from dba_users where username='登录用户'
   

如,我的登录用户是TMS21,那么查询语法是

 /* 查看用户所属的表空间 */
 select default_tablespace from dba_users where username='TMS21';

相关查询的用法,也顺便记录一下

1)查询当前用户表空间

 /* 查看用户所属的表空间 */
 select default_tablespace from dba_users where username='TMS21';

2)查询所有表空间

  /*查看所有的表空间 */
   -- 1 )方式1:dba_tablespaces --
   select * from dba_tablespaces;
    --2 )方式2:v$tablespace --
   select * from v$tablespace;   

3)查询用户下所有表

  /* 查看用户下面的所有的表 */ 
  -- 1 )方式1:user_tables --
   select * from user_tables;
   --2 )方式2: dba_tables --
   select * from dba_tables where owner='TMS21';

4)查询表空间下的用户

  /*查看表空间下有多少用户,tablespace_name表空间 的名字一定要大写 */
   select distinct s.owner from dba_segments s where s.tablespace_name ='TMS21';  

PS:因为我的表空间名称跟用户一样,所以4)中的表空间都是TMS21(以查询结果为主)

资料来源:https://blog.csdn.net/qq_26941173/article/details/77155421