执行完exp/imp之后,可以在imp的log文件中查看到相关表的建表语句,和与该表相关的其他数据库对象的ddl语句,如索引、触发器等。
Ddl操作实际上在内部被转化一系列的dml语句进行执行
跟踪ddl操作,查看Oracle后台数据字典自动执行的内容:
scott@ORCL>conn / as sysdba;
已连接。
sys@ORCL>alter session set events '10046trace name context forever,level 12';
会话已更改。
sys@ORCL>create table trace_ddl asselect * from dba_users;
表已创建。
sys@ORCL>select value from v$diag_infowhere;
VALUE
----------------------------------------
d:\app\lenovo\diag\rdbms\orcl\orcl\trace
\orcl_ora_7460.trc
查看该文件中的内容:
首先记录的创建语句:
PARSING IN CURSOR #2 len=49 dep=0 uid=0oct=1 lid=0 tim=6439856921 hv=1016677043 ad='7ffbd8a2020' sqlid='6urykycy9khpm'
create table trace_ddl as select * fromdba_users
END OF STMT
向obj中增加记录的dml语句
PARSING IN CURSOR #4 len=216 dep=1 uid=0oct=2 lid=0 tim=6439892002 hv=714380553 ad='7ffc849c3c0' sqlid='4bjwv5sp99589'
insert intoobj$(owner#,name,namespace,obj#,type#,ctime,mtime,stime,status,remoteowner,linkname,subname,dataobj#,flags,oid$,spare1,spare2,spare3)values(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14,:15,:16,:17,:18)
END OF STMT
更新con$表的信息:
PARSING IN CURSOR #4 len=61 dep=1 uid=0 oct=6 lid=0 tim=6439918579hv=4246113160 ad='7ffbdca6628' sqlid='bajr90ryjd2w8'
update con$ set con#=:3,spare1=:4 whereowner#=:1 and name=:2
END OF STMT
增加段信息,向seg$表插入数据的语句:
PARSING IN CURSOR #4 len=259 dep=1 uid=0oct=2 lid=0 tim=6440002337 hv=1814305607 ad='7ffbd89ed80' sqlid='g7mt7ptq286u7'
insert into seg$(file#,block#,type#,ts#,blocks,extents,minexts,maxexts,extsize,extpct,user#,iniexts,lists,groups,cachehint,hwmincr,spare1, scanhint, bitmapranges) values(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14,:15,:16,DECODE(:17,0,NULL,:17),:18,:19)
END OF STMT
向col$增加字段信息:
PARSING IN CURSOR #4 len=453 dep=1 uid=0oct=2 lid=0 tim=6440042013 hv=224718466 ad='7ffbdca27b8' sqlid='60uw2vh6q9vn2'
insert intocol$(obj#,name,intcol#,segcol#,type#,length,precision#,scale,null$,offset,fixedstorage,segcollength,deflength,default$,col#,property,charsetid,charsetform,spare1,spare2,spare3)values(:1,:2,:3,:4,:5,:6,decode(:5,182/*DTYIYM*/,:7,183/*DTYIDS*/,:7,decode(:7,0,null,:7)),decode(:5,2,decode(:8,-127/*MAXSB1MINAL*/,null,:8),178,:8,179,:8,180,:8,181,:8,182,:8,183,:8,231,:8,null),:9,0,:10,:11,decode(:12,0,null,:12),:13,:14,:15,:16,:17,:18,:19,:20)
END OF STMT
Oracle通过将ddl解析为dml操作,并且将这些操作全部记录在数据字典中,通过将这些信息反向解析,,可以得到原始的创建语句
通过dbms_metadata可以得到原始的创建语句:
sys@ORCL>SELECTDBMS_METADATA.GET_DDL('TABLE','TRACE_DDL') FROM DUAL;
DBMS_METADATA.GET_DDL('TABLE','TRACE_DDL')
--------------------------------------------------------------------------------
CREATE TABLE "SYS"."TRACE_DDL"
( "USERNAME" VARCHAR2(30)NOT NULL ENABLE,
"USER_ID" NUMBER NOT NULL ENABLE,
"PASSWORD" VARCHAR2(30),
"ACCOUNT_STATUS" VARCHAR2(32) NOT NULL ENABLE,
"LOCK_DATE" DATE,
"EXPIRY_DATE" DATE,
"DEFAULT_TABLESPACE" VARCHAR2(30) NOT NULL ENABLE,
"TEMPORARY_TABLESPACE" VARCHAR2(30) NOT NULL ENABLE,
"CREATED" DATE NOT NULL ENABLE,
"PROFILE" VARCHAR2(30) NOT NULL ENABLE,
"INITIAL_RSRC_CONSUMER_GROUP" VARCHAR2(30),
"EXTERNAL_NAME" VARCHAR2(4000),
"PASSWORD_VERSIONS"VARCHAR2(8),
"EDITIONS_ENABLED" VARCHAR2(1),
"AUTHENTICATION_TYPE" VARCHAR2(8)
)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 DEFAULTFLASH_CACHE DEFAULT CELL_FLA
SH_CACHE DEFAULT)
TABLESPACE "SYSTEM"
查看建表语句有另一个办法:
1. exp username/pwd@service_name file=?rows=n
2. imp username/pwd@service_name file=?show=y log=? tables=?
执行完exp/imp之后,可以在imp的log文件中查看到相关表的建表语句,和与该表相关的其他数据库对象的ddl语句,如索引、触发器等。
如果在imp的参数中以 fromuser, touser 来代替tables,会在log文件中看到该模式内所有对象的ddl语句。
相关阅读:
两台Oracle之间配置OGG-未配置同步DDL
Oracle GoldenGate 11g单向DDL配置实战
Oracle利用dbms_metadata.get_DDL查看DDL语句
Oracle使用系统级触发器禁用DDL语句
Oracle使用系统级触发器审计重要帐号的DDL语句

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

MySQloffersechar, Varchar, text, Anddenumforstringdata.usecharforfixed-Lengthstrings, VarcharerForvariable-Length, text forlarger text, AndenumforenforcingdataAntegritywithaetofvalues.

Optimizing MySQLBLOB requests can be done through the following strategies: 1. Reduce the frequency of BLOB query, use independent requests or delay loading; 2. Select the appropriate BLOB type (such as TINYBLOB); 3. Separate the BLOB data into separate tables; 4. Compress the BLOB data at the application layer; 5. Index the BLOB metadata. These methods can effectively improve performance by combining monitoring, caching and data sharding in actual applications.

Mastering the method of adding MySQL users is crucial for database administrators and developers because it ensures the security and access control of the database. 1) Create a new user using the CREATEUSER command, 2) Assign permissions through the GRANT command, 3) Use FLUSHPRIVILEGES to ensure permissions take effect, 4) Regularly audit and clean user accounts to maintain performance and security.

ChooseCHARforfixed-lengthdata,VARCHARforvariable-lengthdata,andTEXTforlargetextfields.1)CHARisefficientforconsistent-lengthdatalikecodes.2)VARCHARsuitsvariable-lengthdatalikenames,balancingflexibilityandperformance.3)TEXTisidealforlargetextslikeartic

Best practices for handling string data types and indexes in MySQL include: 1) Selecting the appropriate string type, such as CHAR for fixed length, VARCHAR for variable length, and TEXT for large text; 2) Be cautious in indexing, avoid over-indexing, and create indexes for common queries; 3) Use prefix indexes and full-text indexes to optimize long string searches; 4) Regularly monitor and optimize indexes to keep indexes small and efficient. Through these methods, we can balance read and write performance and improve database efficiency.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
