dba_tables视图学习
发表于:2024-11-12 作者:千家信息网编辑
千家信息网最后更新 2024年11月12日,DBA_TABLES描述数据库中的所有关系表。它的列与ALL_TABLES中的列相同。要收集此视图的统计信息,请使用DBMS_STATS包。 ALL_TABLES描述当前用户可以访问的关系表。要收集此
千家信息网最后更新 2024年11月12日dba_tables视图学习DBA_TABLES描述数据库中的所有关系表。它的列与ALL_TABLES中的列相同。要收集此视图的统计信息,请使用DBMS_STATS包。 ALL_TABLES描述当前用户可以访问的关系表。要收集此视图的统计信息,请使用DBMS_STATS包。 USER_TABLES描述当前用户拥有的关系表。此视图不显示所有者列。
获取表的DDL的方法: 1)利用 DBMS_METADATA.GET_DDL,获取表的 DDL 语句 2)imp.indexfile 和 impdp.sqlfile 1)利用 DBMS_METADATA.GET_DDL,获取表的 DDL 语句 参考: How To Obtain Table DDL Without Using DBMS_METADATA.GET_DDL(文档 ID 1922301.1)
Column | Datatype | NULL | Description |
OWNER | VARCHAR2(30) | NOT NULL | Owner of the table 表的拥有者 |
TABLE_NAME | VARCHAR2(30) | NOT NULL | Name of the table 表名 |
TABLESPACE_NAME | VARCHAR2(30) | Name of the tablespace containing the table; NULL for partitioned, temporary, and index-organized tables 指定表所属的表空间,但是通过查询可以发 现有一部分 tablespace 为空的表,一般情况 下要么是分区表,要么是临时表,要么是索引组织表(iot type) | |
CLUSTER_NAME | VARCHAR2(30) | Name of the cluster, if any, to which the table belongs Oracle 提供了多种数据表存储结构。我们最常见的就是三种,分别为堆表(HeapTable)、索引组织表(Index Organization Table,简称为 IOT)和聚簇表(ClusterTable) | |
IOT_NAME | VARCHAR2(30) | Name of the index-organized table, if any, to which the overflow or mapping table entry belongs. If the IOT_TYPE column is not NULL, then this column contains the base table name. 溢出或映射表条目所属的索引组织表的名称(如果有的话)。如果IOT_TYPE列不为空,则此列包含基表名。 | |
STATUS | VARCHAR2(8) | If a previous DROP TABLE operation failed, indicates whether the table is unusable ( UNUSABLE ) or valid ( VALID ) 如果先前的删除表操作失败,则指示该表是不可用的(不可用的)还是有效的(有效的) | |
PCT_FREE | NUMBER | Minimum percentage of free space in a block; NULL for partitioned tables 数据块中剩余百分比的最小值,分区表的话此列为空 | |
PCT_USED | NUMBER | Minimum percentage of used space in a block; NULL for partitioned tables 数据块中使用百分比的最小值,分区表的话此列为空 | |
INI_TRANS | NUMBER | Initial number of transactions; NULL for partitioned tables 事务的初始化值,分区表的话此列为 | |
MAX_TRANS | NUMBER | Maximum number of transactions; NULL for partitioned tables 事务的最大值,分区表的话此列为空 | |
INITIAL_EXTENT | NUMBER | Size of the initial extent (in bytes); NULL for partitioned tables 初始化 extent 大小(以字节为单位),分区表的话此列为空 | |
NEXT_EXTENT | NUMBER | Size of secondary extents (in bytes); NULL for partitioned tables 下一个 extent 分配大小,分区表的话此列为空 | |
MIN_EXTENTS | NUMBER | Minimum number of extents allowed in the segment; NULL for partitioned tables 段中分配的区中的最小值,分区表的话此列为空 | |
MAX_EXTENTS | NUMBER | Maximum number of extents allowed in the segment; NULL for partitioned tables 段中分配的区中的最大值,分区表的话此列为空 | |
PCT_INCREASE | NUMBER | Percentage increase in extent size; NULL for partitioned tables 在 extents 中,增长的比例,分区表的话此列为空 | |
FREELISTS | NUMBER | Number of process freelists allocated to the segment; NULL for partitioned tables 分配到段中自由列表的数量,分区表的话此列为空 | |
FREELIST_GROUPS | NUMBER | Number of freelist groups allocated to the segment; NULL for partitioned tables 分配到段中的自由列表组数量,分区表的话此列为空 | |
LOGGING | VARCHAR2(3) | Indicates whether or not changes to the table are logged; NULL for partitioned tables:
| |
BACKED_UP | VARCHAR2(1) | Indicates whether the table has been backed up since the last modification (Y) or not (N) 在上一次修改过后是否备份 | |
NUM_ROWS* | NUMBER | Number of rows in the table 表的行数 | |
BLOCKS* | NUMBER | Number of used data blocks in the table 表使用过的数据块数 | |
EMPTY_BLOCKS | NUMBER | Number of empty (never used) data blocks in the table. This column is populated only if you collect statistics on the table using the DBMS_STATS package. 表中的空块数,即没有使用的块 只有在使用DBMS_STATS包收集表上的统计信息时,才会填充此列 | |
AVG_SPACE* | NUMBER | Average amount of free space, in bytes, in a data block allocated to the table 分配给表的数据块中的平均可用空间量(以字节为单位) | |
CHAIN_CNT* | NUMBER | Number of rows in the table that are chained from one data block to another, or which have migrated to a new block, requiring a link to preserve the old ROWID 表中从一个数据块链接到另一个数据块的行数,或者已经迁移到新块的行数,需要一个链接来保存旧的ROWID 表中跨越多个块的行数量 | |
AVG_ROW_LEN* | NUMBER | Average length of a row in the table (in bytes) 表中一行的平均长度(以字节为单位) | |
AVG_SPACE_FREELIST _BLOCKS | NUMBER | Average freespace of all blocks on a freelist 自由列表中所有块的平均自由空间 | |
NUM_FREELIST_BLOCKS | NUMBER | Number of blocks on the freelist 自由列表上的块数 | |
DEGREE | VARCHAR2(10) | Number of threads per instance for scanning the table, or DEFAULT 每个实例有多少线程可以同时扫描表或者表的默认并行为 1 | |
INSTANCES | VARCHAR2(10) | Number of instances across which the table is to be scanned, or DEFAULT 多少实例可以同时扫描表,默认值为1 | |
CACHE | VARCHAR2(5) | Indicates whether the table is to be cached in the buffer cache (Y) or not (N) 是否是要在缓冲区高速缓存 ( Y ) or ( N ) | |
TABLE_LOCK | VARCHAR2(8) | Indicates whether table locking is enabled (ENABLED) or disabled (DISABLED) 是否锁表 ( ENABLED ) or ( DISABLED ) | |
SAMPLE_SIZE | NUMBER | Sample size used in analyzing this table 分析这个表所使用的样本大小 | |
LAST_ANALYZED | DATE | Date on which this table was most recently analyzed 最近一次分析表的时间 | |
PARTITIONED | VARCHAR2(3) | Indicates whether the table is partitioned (YES) or not (NO) 是否是分区表 | |
IOT_TYPE | VARCHAR2(12) | If the table is an index-organized table, then IOT_TYPE is IOT, IOT_OVERFLOW, or IOT_MAPPING. If the table is not an index-organized table, then IOT_TYPE is NULL. 如果表是一个索引组织的表,那么IOT_TYPE是IOT、IOT_OVERFLOW或IOT_MAPPING。如果表不是索引组织的表,则IOT_TYPE为空。 | |
TEMPORARY | VARCHAR2(1) | Indicates whether the table is temporary (Y) or not (N) 是否是临时表 | |
SECONDARY | VARCHAR2(1) | Indicates whether the table is a secondary object created by the ODCIIndexCreate method of the Oracle Data Cartridge (Y) or not (N) 是否是通过 ODCIIndexCreate 方法创建的辅助对象 | |
NESTED | VARCHAR2(3) | Indicates whether the table is a nested table (YES) or not (NO) 是否是 nested 表 ( YES ) or ( NO | |
BUFFER_POOL | VARCHAR2(7) | Buffer pool for the table; NULL for partitioned tables:
| |
FLASH_CACHE | VARCHAR2(7) | Database Smart Flash Cache hint to be used for table blocks:(11g才有)
| |
CELL_FLASH_CACHE | VARCHAR2(7) | Cell flash cache hint to be used for table blocks:
| |
ROW_MOVEMENT | VARCHAR2(8) | Indicates whether partitioned row movement is enabled (ENABLED) or disabled (DISABLED) 行迁移是否开启 | |
GLOBAL_STATS | VARCHAR2(3) | For partitioned tables, indicates whether statistics for the table as a whole (global statistics) are accurate (YES) or whether they were not collected and have to be estimated from statistics on underlying partitions and subpartitions (NO) 对于分区表,指示整个表的统计信息(全局统计信息)是否准确(YES),或者是否没有收集这些信息,并且必须根据底层分区和子分区的统计信息进行估计(NO) 作为一个整体(分区表)表的统计的是否准确表示是否被用户统计信息 ( YES ) or ( NO ) | |
USER_STATS | VARCHAR2(3) | Indicates whether statistics were entered directly by the user (YES) or not (NO) 表示是否被用户统计信息 ( YES ) or ( NO ) | |
DURATION | VARCHAR2(15) | Indicates the duration of a temporary table:
| |
SKIP_CORRUPT | VARCHAR2(8) | Indicates whether Oracle Database ignores blocks marked corrupt during table and index scans (ENABLED) or raises an error (DISABLED). To enable this feature, run the DBMS_REPAIR.SKIP_CORRUPT_BLOCKS procedure. 在表和索引扫描时候是否无视标记为 corrupt的块. 如果要起用,则执行 DBMS_REPAIR . SKIP_CORRUPT_BLOCKS | |
MONITORING | VARCHAR2(3) | Indicates whether the table has the MONITORING attribute set (YES) or not (NO) 表是否设置了 MONITORING 属性 | |
CLUSTER_OWNER | VARCHAR2(30) | Owner of the cluster, if any, to which the table belongs 簇表的拥有者 | |
DEPENDENCIES | VARCHAR2(8) | Indicates whether row-level dependency tracking is enabled (ENABLED) or disabled (DISABLED) 行级依赖跟踪是否开启( ENABLED ) or ( DISABLED ) | |
COMPRESSION | VARCHAR2(8) | Indicates whether table compression is enabled (ENABLED) or not (DISABLED); NULL for partitioned tables 表是否压缩 | |
COMPRESS_FOR | VARCHAR2(12) | Default compression for what kind of operations:(11g才有)
| |
DROPPED | VARCHAR2(3) | Indicates whether the table has been dropped and is in the recycle bin (YES) or not (NO); NULL for partitioned tables 表是否被 DROP 到了回收站中 | |
READ_ONLY | VARCHAR2(3) | Indicates whether the table IS READ-ONLY (YES) or not (NO) (11g才有) 表是否是只读的 | |
SEGMENT_CREATED | VARCHAR2(3) | Indicates whether the table segment is created (YES) or not (NO) (11g才有) 表的段是否创建 | |
RESULT_CACHE | VARCHAR2(7) | Result cache mode annotation for the table: (11g才有)
| |
首先运行set echo offset heading offset feedback offset verify offset pagesize 0set linesize 132define schema=&1输入schema的名字然后执行:define CR=chr(10)define TAB=chr(9)col x noprintcol y noprintSELECT TABLE_NAME Y ,0 X ,'CREATE TABLE ' || RTRIM(TABLE_NAME) || '('FROM DBA_TABLESWHERE OWNER = UPPER('&schema')UNIONSELECT TC.TABLE_NAME Y ,COLUMN_ID X ,DECODE(COLUMN_ID, 1, ' ', ' ,') || RTRIM(COLUMN_NAME) || &TAB || &TAB || RTRIM(DATA_TYPE) || RTRIM(DECODE(DATA_TYPE, 'DATE', NULL, 'LONG', NULL, 'NUMBER', DECODE(TO_CHAR(DATA_PRECISION), NULL, NULL, '('), '(')) || RTRIM(DECODE(DATA_TYPE, 'DATE', NULL, 'CHAR', DATA_LENGTH, 'VARCHAR2', DATA_LENGTH, 'NUMBER', DECODE(TO_CHAR(DATA_PRECISION), NULL, NULL, TO_CHAR(DATA_PRECISION) || ',' || TO_CHAR(DATA_SCALE)), 'LONG', NULL, '******ERROR')) || RTRIM(DECODE(DATA_TYPE, 'DATE', NULL, 'LONG', NULL, 'NUMBER', DECODE(TO_CHAR(DATA_PRECISION), NULL, NULL, ')'), ')')) || &TAB || &TAB || RTRIM(DECODE(NULLABLE, 'N', 'NOT NULL', NULL))FROM DBA_TAB_COLUMNS TC ,DBA_OBJECTS OWHERE O.OWNER = TC.OWNER AND O.OBJECT_NAME = TC.TABLE_NAME AND O.OBJECT_TYPE = 'TABLE' AND O.OWNER = UPPER('&schema')UNIONSELECT TABLE_NAME Y ,999999 X ,')' || &CR || ' STORAGE(' || &CR || ' INITIAL ' || INITIAL_EXTENT || &CR || ' NEXT ' || NEXT_EXTENT || &CR || ' MINEXTENTS ' || MIN_EXTENTS || &CR || ' MAXEXTENTS ' || MAX_EXTENTS || &CR || ' PCTINCREASE ' || PCT_INCREASE || ')' || &CR || ' INITRANS ' || INI_TRANS || &CR || ' MAXTRANS ' || MAX_TRANS || &CR || ' PCTFREE ' || PCT_FREE || &CR || ' PCTUSED ' || PCT_USED || &CR || ' PARALLEL (DEGREE ' || RTRIM(DEGREE) || ') ' || &CR || ' TABLESPACE ' || RTRIM(TABLESPACE_NAME) || &CR || '/' || &CR || &CRFROM DBA_TABLESWHERE OWNER = UPPER('&schema')ORDER BY 1 ,2或者
set pagesize 0set long 90000set feedback offset echo offspool table_ddl.sqlselect dbms_metadata.get_ddl('TABLE','tablename','username') from dual;select dbms_metadata.get_ddl('VIEW','viewname','username') from dual;select dbms_metadata.get_ddl('INDEX','indexname','username') from dual;spool off;例如:set pagesize 0set long 90000set feedback offset echo offspool table_ddl.sqlselect dbms_metadata.get_ddl('TABLE','DEMO2','DEMO') from dual;select dbms_metadata.get_ddl('INDEX','IDX_ID_DEMO2','DEMO') from dual;spool off;[oracle@oracle11g ~]$ cat table_ddl.sqlSQL> select dbms_metadata.get_ddl('TABLE','DEMO2','DEMO') from dual; CREATE TABLE "DEMO"."DEMO2" ( "OWNER" VARCHAR2(30), "OBJECT_NAME" VARCHAR2(128), "SUBOBJECT_NAME" VARCHAR2(30), "OBJECT_ID" NUMBER, "DATA_OBJECT_ID" NUMBER, "OBJECT_TYPE" VARCHAR2(19), "CREATED" DATE, "LAST_DDL_TIME" DATE, "TIMESTAMP" VARCHAR2(19), "STATUS" VARCHAR2(7), "TEMPORARY" VARCHAR2(1), "GENERATED" VARCHAR2(1), "SECONDARY" VARCHAR2(1), "NAMESPACE" NUMBER, "EDITION_NAME" VARCHAR2(30) ) SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS" SQL> select dbms_metadata.get_ddl('INDEX','IDX_ID_DEMO2','DEMO') from dual; CREATE INDEX "DEMO"."IDX_ID_DEMO2" ON "DEMO"."DEMO2" ("OBJECT_ID") PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS" SQL> spool off;2)imp.indexfile 和 impdp.sqlfile
#示例:1.indexfile1)先导出用户的数据[oracle@oracle11g ~]$ exp demo/demo file=test.dmp owner=demo log=test.log;2)从 dump 文件获取这些 DDL 语句[oracle@oracle11g ~]$ imp demo/demo file=test.dmp fromuser=demo touser=demo indexfile=test.sql;
2.sqlfile
导出用户数据[oracle@oracle11g ~]$ expdp demo/demo directory=DATA_PUMP_DIR dumpfile=sqlfile.dmp schemas=demo;获取 DDL 语句[oracle@oracle11g ~]$ impdp demo/demo directory=DATA_PUMP_DIR dumpfile=sqlfile.dmp sqlfile=demo.sql;
分区表
此列
数据
信息
统计
用户
索引
自由
语句
分配
视图
最小
单位
大小
字节
数量
空间
缓存
要么
最大
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
求生之路怎么在社区添加服务器
广东微商软件开发市场价
安徽app订制软件开发
网络安全手抄报有趣
宝鸡库克酷网络技术有限公司
国家 网络安全战略
国外伪造发包服务器
深圳纵横软件开发有限公司
天元网络技术有限公司招聘
网络安全等级测评工具用不了
阆中租房软件开发
鹏鼎软件开发
vpn服务器地址免费
电脑时间与时间服务器不能同步
重庆大足食堂配送软件开发
在数字技术网络技术
acl网络安全实战
浏览器服务器结构是什么原因
2017网络安全自查表
南京银行软件开发岗笔试题型
登录页面时服务器的连接被重置
山东博赛网络技术讲师
网络安全文件学习相关要求
国家 网络安全战略
疫情期间同上网络安全
查询数据库学生表的代码解析
网络安全问题的感想
h2数据库源代码分析
康复人才实名制数据库
网络安全宣传周西安闭幕