Oracle 8i: full sql text in v$sqlarea
I work with oracle 8i.
is there a v$... that shows the execution plan for a query.
in thev$sqlarea there isn't the full_sqltext column, and I need to know what oracle is doing now.
Message was edited by:
user596611
v$sqltext_with_newlines will produce multiple rows per statement.
You'll need an inline view
select t.hash_value, t.sorts, t.executions, t.buffer_gets, t.disk_reads, tn.sql_text
from v$sqlarea t,
(select hash_value,sql_text
from v$sqltext_with_newlines
order by hash_value, piece) tn
where sn.hash_value = t.hash_value
Sybrand Bakker
Senior Oracle DBA
Similar Messages
-
FULL SQL TEXT를 찾는 방법
PURPOSE
전통적으로 특정 process가 실행하고 있는 SQL을 살펴보기 위해 V$SQL / V$SQL_TEXT 등의 view가 사용됩니다. 다만, varchar2 datatype이므로 full SQL을 볼 수 없다는 제한이 있습니다.
10g 부터는 SQL_FULLTEXT 라는 CLOB 형태의 컬럼을 통해 1000 byte 가 넘는 SQL text도 열람할 수 있게 되었습니다.
CONTENTS
1. test에 사용할 SQL text
2. 전통적 방법으로 접근
3. 새로운 방법으로 접근
4. 요약
1. 다음과 같은 TEST 목적의 query가 있습니다. 영문캐릭터만 사용하여 SELECT 부터 DUAL까지 1125 글자이므로, 1125 bytes 입니다.
select /* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa */ * from dual;
이 query를 SCOTT 으로 수행해봅니다.
2. 전통적 방법으로 접근
새로운 SESSION을 열어 다음과 같이, SCOTT 으로 접속된 SESSION의 sid 및 serial# 를 확인합니다.
(1) USERNAME을 통해 sid 및 serial# 를 확인
select b.sid, b.serial#, b.username
from v$session b where b.username ='SCOTT';
SID SERIAL# USERNAME
309 1198 SCOTT
(2) 확인된 정보를 통해, SQL TEXT를 확인합니다.
VARCHAR2(1000)에 저장된 DATA 이므로, 다음과 같이 FULL SQL은 확보하지 못했습니다.
set linesize 50
column sql_fulltext format a60 word_wrap
break on sql_text skip 1
select s.username username, s.osuser, s.program, a.sql_text SQL
from v$sql a, v$session s
where s.sid = 309 and s.serial# = 1198
and a.address = s.sql_address and a.hash_value = s.sql_hash_value;
USERNAME
OSUSER
PROGRAM
SQL
SCOTT
oracle
[email protected] (TNS V1-V3)
select /* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
USERNAME
OSUSER
PROGRAM
SQL
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
USERNAME
OSUSER
PROGRAM
SQL
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
USERNAME
OSUSER
PROGRAM
SQL
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
USERNAME
OSUSER
PROGRAM
SQL
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
3. 새로운 방법으로 접근
새로운 SESSION을 열어 다음과 같이, SCOTT 으로 접속된 SESSION의 sid 및 serial# 를 확인합니다.
(1) USERNAME을 통해 sid 및 serial# 를 확인
select s.username username, s.osuser, s.program, a.sql_text SQL
from v$sql a, v$session s
where s.sid = 309 and s.serial# = 1198
and a.address = s.sql_address and a.hash_value = s.sql_hash_value;
SID SERIAL# USERNAME
309 1198 SCOTT
(2) 확인된 정보를 통해, SQL TEXT를 확인합니다.
VARCHAR2(1000)에 저장된 DATA 이므로, CLOB datatype인 SQL_FULLTEXT 컬럼에 접근하였으므로 full SQL text를 확보할 수 있습니다.
set linesize 50
column sql_fulltext format a60 word_wrap
break on sql_text skip 1
select
replace(translate(a.sql_fulltext,'0123456789','999999999'),'9','')
SQL_FULLTEXT
from v$sql a, v$session s
where
s.sid = 309 and s.serial# = 1198
and a.address = s.sql_address and a.hash_value = s.sql_hash_value
and a.sql_text like '%aaaaaaaaaaa%'
group by replace(translate(a.sql_fulltext,'0123456789','999999999'),'9','');
set linesize 50
column sql_fulltext format a60 word_wrap
break on sql_text skip 1
SQL_FULLTEXT
select /*
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
SQL_FULLTEXT
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
SQL_FULLTEXT
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
*/ * from dual
4. 요약
10g 이상 버젼에서는, 다음과 같은 형태의 query를 응용함으로서 FULL SQL TEXT를 확보할 수 있습니다.
select
replace(translate(sql_fulltext,'0123456789','999999999'),'9','')
SQL_FULLTEXT
from v$sql
where sql_text like '%<찾고자_하는_SQL_KEYWORD>%'
group by replace(translate(sql_fulltext,'0123456789','999999999'),'9','')
NOTE
혹시라도 SQL TEXT가 4000 BYTE 이상 저장되어 있는 경우라면, ORA-22835 가 발생합니다. (VARCHAR2 형태로 출력되는 과정에서 최대 4000 BYTE 라는 제한조건이 발생됩니다) 이 경우, 다음과 같이 4000 byte만 읽도록 DBMS_LOB.SUBSTR()을 설정해줄 수 있습니다.
*** BEFORE
replace(translate(sql_fulltext,'0123456789','999999999'),'9','')
*** AFTER
replace(translate(dbms_lob.substr(a.sql_fulltext,4000,1),'0123456789','999999999'),'9','')
만약 4000 BYTE 이상의 SQL text 가 모두 필요, java/proc/developer 등의 CLOB 처리가 가능한 3rd part tool를 사용해주시거나, 필요한 APP를 작성해주셔야 합니다.
References
Note 437304.1스크립트의 RMAN 구동 후 돌려 주시는 구문 중에 $db_bk_sql 호출하여 백업을 받으시는데 채널 할당하는 부분에 format 구문을 넣어서 각 채널에서 저장하는 위치을 다르게 잡아 줄 수 있습니다. 대신 쓰시는 backup database 구문에서 format 관련된 부분을 빼 주셔야 합니다...
예로
ALLOCATE CHANNEL disk1 DEVICE TYPE DISK FORMAT '/disk1/backups/%U';
뒤으 %U는 구분을 해 주기위해서 쓴 구문이구요... 위 구문과 같은 형식으로 채널 할당을 조절해 주시면 원하시는 대로 백업을 나누어서 할 수 있을 겁니다...
추가적으로 더 다양한 형식으로 컨트롤을 할 수 있지만 그런 부분들은 백업 정책 및 기타 고려 사항을 참고해서 구성을 하셔야 입맛에 맞게 조절할 수 있으리라 봅니다.
글 수정:
명품 관 -
Find the full sql text of the currently executing query
Hi,
I wish to find the full sql text of currently executing sql.
Tried through v$sql and v sqltext_with_newlines but it doesn't give the full sql.
We do not want to enable trace to get sql query.
How to get this ?
Thanks.Hye,
I got my answer on the below link,
Getting data from sql_fulltext
Thanks. -
11.2.0.3.5 / 2 node rac on rhel-6 / 64-bit
I would like to a profile a sql_id since its following 4 plans and one of them is the optimal.
But im unable to do it as it throwing ORA-13786.
Steps I followed :
{code}
SET SERVEROUTPUT ON
-- Tuning task created for specific a statement from the AWR.
DECLARE
l_sql_tune_task_id VARCHAR2(100);
BEGIN
l_sql_tune_task_id := DBMS_SQLTUNE.create_tuning_task (
begin_snap => 29676,
end_snap => 29707,
sql_id => 'fjndcnvzkjkb5',
scope => DBMS_SQLTUNE.scope_comprehensive,
time_limit => 60,
task_name => '420tavt57dxkx_tuning_task',
description => 'Tuning task for statement 420tavt57dxkx in AWR.');
DBMS_OUTPUT.put_line('l_sql_tune_task_id: ' || l_sql_tune_task_id);
END;
EXEC DBMS_SQLTUNE.execute_tuning_task(task_name => 'fjndcnvzkjkb5_CFO_tuning_task');
SET LONG 10000;
SET PAGESIZE 1000
SET LINESIZE 200
SELECT DBMS_SQLTUNE.report_tuning_task('420tavt57dxkx_tuning_task') AS recommendations FROM dual;
SET PAGESIZE 24
SQL> execute dbms_sqltune.accept_sql_profile(task_name =>'420tavt57dxkx_tuning_task_task', replace => TRUE,force_match => TRUE);
BEGIN dbms_sqltune.accept_sql_profile(task_name =>420tavt57dxkx_tuning_task', replace => TRUE,force_match => TRUE); END;
ERROR at line 1:
ORA-13786: missing SQL text of statement object "1" for tuning task "420tavt57dxkx_tuning_task"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.DBMS_SQLTUNE_INTERNAL", line 16442
ORA-06512: at "SYS.PRVT_SQLPROF_INFRA", line 31
ORA-06512: at "SYS.DBMS_SQLTUNE", line 7544
ORA-06512: at "SYS.DBMS_SQLTUNE", line 7568
ORA-06512: at line 1
{code}
Can somebody help me out on this?Hi Experts,
i too getting this error while attaching the tuning task to the sql profiler, below are the details, appreciate any help on this.
SQL> SQL> VAR profile_name VARCHAR2(30);
SQL> BEGIN
:profile_name := DBMS_SQLTUNE.ACCEPT_SQL_PROFILE(task_name => 'sql_tuning_task');
END;
/ 2 3 4
BEGIN
ERROR at line 1:
ORA-13786: missing SQL text of statement object "1" for tuning task "sql_tuning_task"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.DBMS_SQLTUNE_INTERNAL", line 16442
ORA-06512: at "SYS.PRVT_SQLPROF_INFRA", line 31
ORA-06512: at "SYS.DBMS_SQLTUNE", line 7544
ORA-06512: at line 2
SQL> select banner from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production -
Sql statements in v$sqlarea
Hi
When I get the sqls from v$sqlarea, does these sqls already executed, or currently runnıng?I suggest you check the Oracle Document,
While showing similar content, you might also note there are difference between V$SQLAREA and V$SQL view
V$SQL
V$SQL lists statistics on shared SQL area without the GROUP BY clause and contains one row for each child of the original SQL text entered. Statistics displayed in V$SQL are normally updated at the end of query execution. However, for long running queries, they are updated every 5 seconds. This makes it easy to see the impact of long running SQL statements while they are still in progress.
V$SQLAREA
V$SQLAREA lists statistics on shared SQL area and contains one row per SQL string. It provides statistics on SQL statements that are in memory, parsed, and ready for execution. -
Hi all,
i checked from sid,serial#,sql_id from gv$session_longops where time_remaining!=0;
i would like to check the complete sql_text that is executing.
I have tried from select sql_fulltext from gv$sql; but i can't able to see complete sql command.
could you please tell me, how i can get the complete sql text.
I am using: -
Putty to access HP UNIX box
oracle 11gUse v$sqlarea.sql_fulltext
select sql_fulltext from v$sqlarea
where sql_id in (select sql_id from gv$session_longops where time_remaining!=0)Edited by: Chinar on Jan 3, 2011 5:48 AM -
How to extract sql text with SID and SERIAL#
Hi,
I am new to oracle database and recently i have started my journey in performance tuning.
i need to extract sql text which is fired by user based ont SID and SERIAL#.
Thanks in advance..
prabhaseankim wrote:
Hi~
select a.sid, a.serial#, b.sql_fulltext
from v$session a, v$sql b
where decode(a.sql_id,null,a.prev_sql_id, a.sql_id)=b.sql_id
and decode(a.sql_id,null,a.prev_child_number, a.sql_child_number)=b.child_number
and a.sid=&sid
and a.serial#=&serial;
Also a bad idea - have you checked the exection plan ?
Do you think it might be a good idea to think about the need for statistics on fixed objects ?
Here's a possible plan from 11.1.0.7 - and it's not very nice.
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 2182 | 0 (0)| 00:00:01 |
| 1 | NESTED LOOPS | | 1 | 2182 | 0 (0)| 00:00:01 |
| 2 | MERGE JOIN CARTESIAN | | 1 | 2075 | 0 (0)| 00:00:01 |
| 3 | NESTED LOOPS | | 1 | 39 | 0 (0)| 00:00:01 |
|* 4 | FIXED TABLE FIXED INDEX| X$KSLWT (ind:1) | 1 | 26 | 0 (0)| 00:00:01 |
|* 5 | FIXED TABLE FIXED INDEX| X$KSLED (ind:2) | 1 | 13 | 0 (0)| 00:00:01 |
| 6 | BUFFER SORT | | 1 | 2036 | 0 (0)| 00:00:01 |
|* 7 | FIXED TABLE FULL | X$KGLCURSOR_CHILD | 1 | 2036 | 0 (0)| 00:00:01 |
|* 8 | FIXED TABLE FIXED INDEX | X$KSUSE (ind:1) | 1 | 107 | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
4 - filter("W"."KSLWTSID"=82)
5 - filter("W"."KSLWTEVT"="E"."INDX")
7 - filter("INST_ID"=USERENV('INSTANCE'))
8 - filter("S"."INDX"=82 AND "S"."KSUSESER"=53 AND "S"."INST_ID"=USERENV('INSTANCE')
AND BITAND("S"."KSSPAFLG",1)<>0 AND BITAND("S"."KSUSEFLG",1)<>0 AND
"KGLOBT03"=DECODE("S"."KSUSESQI",NULL,"S"."KSUSEPSI","S"."KSUSESQI") AND
"KGLOBT09"=DECODE("S"."KSUSESQI",NULL,DECODE("S"."KSUSEPCH",65535,TO_NUMBER(NULL),"S"."K
SUSEPCH"),DECODE("S"."KSUSESCH",65535,TO_NUMBER(NULL),"S"."KSUSESCH")))You need to avoid the "full tablescan" of the library cache.
Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com -
Questions About Chapter 2 in Oracle DB 10g: SQL Fundamentals II
Hello,
first of all i'm glad to be a member of your forum. I have joined a beginner Oracle Course: Intro to SQL. I'm facing some problems understanding some concepts in Chapter 2 of Oracle Database 10g: SQL Fundamentals II text book. I got about 15 questions. However, i will only ask two questions at first. Since i'm a newbie, please answer it in a simplistic form. Excuse me if you see grammatical mistakes.
Dropping a column can take a while if the column has a large number of values. In this case it may be better to set it to be unused and drop it when the number of users on the system are fewer to avoid extended locks.
Questions:
"when the number of users on the system are fewer to avoid extended locks."
1. Can you explain this to me please?! fewer than before? fewer than? What if users kept increasing during the years! then this "fewer" may not happen until the company collapse!
2. Why do we need to use unused columns? When should we use unused columns?Great! .... I got more questions, i just do not want to open a new same thread. Thus, i will just post the questions in here and i hope i will get help from experts...Please bare with me guys...The questions are numbered, unnumbered parts are information that helps you understand my question.
Note: just answer what you are willing to, one question or whatever you want. I'm not expecting to get all the answers from one member :)
Thanks for understanding
Page 2-7:
Certain columns can never be dropped such as columns that form part of the partitioning
key for a partitioned table or columns that form part of the primary key of an index- organized table.
Questions:
"columns that form part of the partitioning key for a partitioned table"
*1. Do they mean one table can be split into two different storage? What is the thing that*
link these both tables to make Oracle Server realize these two tables are actually one table? Is is tablespace_name?
"columns that form part of the primary key of an index-organized table."
*2. Can you clarify the above sentence please*
*3. If i have set of columns that has large amount of data, i rather set them unused then*
drop them because the response time is going to be faster! I do not get it, can you
explain please? What i know is drop drops the column and release the disk space whilst
unused column make the columns useless and does not release disk space yet until we drop them, so
drop column does it in one step unlike taking the unused column process. In brief, i would like to know
why dropping unused columns that has large set of data is faster then dropping the column
directly...
Page 2-12
4. ALTER TABLE emp2 ADD CONSTRAINT emp_dt_fk
FOREIGN KEY (Department_id)
REFERENCES departments ON DELETE CASCADE);
The above query is written in text book. I think it should be written as
ALTER TABLE emp2 ADD CONSTRAINT emp_dt_fk
FOREIGN KEY (Department_id)
REFERENCES departments(dept_id) ON DELETE CASCADE;
Am i correct?
*5. Can you tell me what deferring constraints is in one sentence please? Why do we need it? When do we need it in real-life?*
*7. You can defer checking constraints for validity until the end of the transaction. A*
constraint is deferred if the system checks that it is satisfied only on commit. If a
deferred constraint is violated, then commit causes the transaction to roll back.
I do not understand the above paragraph, please explain. What i know is "end of
transaction" ends with ; or commit
Page 2-18
create table test1 (
pk NUMBER PRIMARY KEY,
fk NUMBER,
col1 NUMBER,
col2 NUMBER,
CONSTRAINT fk_constraint FOREIGN KEY (fk) REFERENCES test1,
CONSTRAINT ck1 CHECK (pk > 0 and col1 > 0),
CONSTRAINT ck2 CHECK (col2 > 0) );
-- "CONSTRAINT fk_constraint FOREIGN KEY (fk) REFERENCES test1"
*8. This is wrong isn't it? It references to test1 but no column specified.*
An error is returned for the following statements:
ALTER TABLE test1 DROP (pk); -- pk is a parent key.
*9. We can not drop it because we did not mention ON DELETE CASCADE. Am i right?*
ALTER TABLE test1 DROP (col1) -- col1 is referenced by multicolumn constraint ck1.
*10. I do not get it, can you explain please. col1 is not referenced, i see CHECK constraint is applied*
but no references made. Secondly, is ck1 considered multicolumn because it check two columns?
Or multicolumn here represents something else?
ALTER TABLE emp2
DROP COLUMN employee_id CASCADE CONSTRAINTS;
*11. This drop employee_id column and all its child. Correct?*
ALTER TABLE test1
DROP (pk, fk, col1) CASCADE CONSTRAINTS;
*12. This drops three columns and all its child if there are any. Correct?*
*13. Then what's the difference between ON DELETE CASCADE and CASCADE CONSTRAINTS?*
For example, What if employee_id in emp2 table definition does not have ON DELETE CASCADE,
will CASCADE CONSTRAINTS work? Please explain...
Page 2-22
When you are expecting a large data load and want to speed the operation. You may want
to disable the constraints while performing the load and then enable them, in which case
having a unique index on the primary key will still cause the data to be verified during
the load. So you can first create a nonunique index on the column designated as PRIMARY
KEY, and then create the PRIMARY KEY column and specify that it should use the existing
index.
Example:
1. create the table
create table new_emp
(employee_id number(6),
first_name varchar2(10)
2. create the index
create index emp_id_idx2 on new_emp(employee_id);
"You may want to disable the constraints while performing the load and then enable them"
so i suggest to load all data i want into new_emp.
3. create the primary key
alter table new_emp ADD primary key (employee_id) USING index emp_id_idx2;
What i understand is the following:
If we want to load large data into the new_emp, its better to create the table without any
constraints - in our case the constraint is primary key. After that, we create nonunique
index points to employee_id and then load data into new_emp. Finally, specify employee_id
as primary key using the nonunique index.
*14. Is my explanation correct?*
"in which case having a unique index on the primary key will still cause the data to be
verified during the load."
*15. Data to be verified against what? Is it to be verified whether its NULL or NOT NULL? I*
know primary key does not take NULL and every value must be unique.
After loading all data we want, what if i did
"alter table new_emp ADD primary key (employee_id);"
*16. Will i face any problems or inefficient process?*
I do not think we need step two, we could do the following:
1. create the table
create table new_emp
(employee_id number(6),
first_name varchar2(10)
"You may want to disable the constraints while performing the load and then enable them"
so i suggest to load all data i want itno new_emp.
2. create the primary key
alter table new_emp ADD primary key (employee_id);
*17. The above steps are as efficient as the three steps i mentioned above. The only difference*
is we let index be created implicitly. Right? If no, why?
Page 2-23
CREATE INDEX upper_dept_name_idx ON dept2(UPPER(department_name));
The following statement may use the index, but without the WHERE clause the
Oracle server may perform a full table scan:
select *
from employees
where UPPER(last_name) IS NOT NULL
ORDER BY UPPER (last_name);
"but without the WHERE clause the Oracle server may perform a full table scan"
*18. The above query let oracle server perform full table scan anyway! Right? It has to go*
through every field and check is it not null or not. I know we are using function-based
index but there are alot of not null last_name! so oracle server must scan one by one. If
we only had one not null field, then i would say Oracle server can point to that field
immediately by the aid of function-based index we created above. Can you clarify please...
Another related topic statement that i do not get it yet:
"The oracle server treats indexes with columns marked DESC as function-based indexes."
*19. The bove statements is so general. What if we have a column ordered by DESC order and we*
did not create any function-based indexes, will statement be true?!
Lets go back the above query:
ORDER BY UPPER (last_name);
*20. Its not DESC. To me, the above query does not flow with this statement "The oracle server treats*
*indexes with columns marked DESC as function-based indexes."?*
Page 2-27
Regarding FLASHBACK TABLE, you can invoke a flashback table operation on one or more
tables, even on tables in different schema. You specify the point in time to which you
want to revert by providing a valid timestamp. By default, database triggers are disabled
for all tables involved. You can override this default behavior by specifying the ENABLE
TRIGGERS clause.
"By default, database triggers are disabled for all tables involved. You can override this
default behavior by specifying the ENABLE TRIGGERS clause."
*21. What are database triggers?*
*22. About External Tables. What are external tables? When is it used in real-life? Why do*
we want External Tables?
Page 2-30
Oracle server provides two major access drivers for external tables. They are
ORACLE_LOADER access driver and ORACLE_DATAPUMP access driver. ORACLE_DATAPUMP used to
both import and export data using a platform-independent format.
"platform-independent format."
*23. What is the format? Is it .dat?*
Page 2-35
CREATE TABLE oldemp ( fname char(25), lname char(25) )
ORGANIZATION EXTERNAL
(TYPE ORACLE_LOADER
DEFAULT DIRECTORY emp_dir
ACCESS PARAMETERS
(RECORDS DELIMINATED BT NEWLINE
NOBADFILE
NOLOGFILE
FIELDS TERMINATED BY ',' (fname POSITION (1:20) CHAR, lname POSITION (22:41) CHAR)
LOCATION ('emp.dat') )
PARALLEL 5
REJECT LIMIT 200;
*24. Can you please explain the below part:*
ACCESS PARAMETERS
(RECORDS DELIMINATED BT NEWLINE
NOBADFILE
NOLOGFILE
FIELDS TERMINATED BY ',' (fname POSITION (1:20) CHAR, lname POSITION (22:41) CHAR)
*25. Can you please explain what is PARALLEL 5? and Why do we need it?*
Again, any help is appreciated...
Edited by: user11164565 on Jul 21, 2009 4:41 AM -
Unable to configure Oracle Publisher in SQL SERVER 2008 R2
Hi, All,
I am trying to talk to my Oracle database from SQL server. I already had Oracle Client 11g installed in my SQL server.
Following the guidance in the technet on configuring the Distributer successfully. I now trying to configure the Publisher, by choosing "Adding Oracle Publisher" option. Then it prompt for the user id & password, I have enter the login (which
is replication user id created in Oracle). I encounter following error msg:
TITLE: Distributor Properties
Oracle server instance 'ssluat' cannot be enabled as a Publisher because of the following error:
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1600.1&EvtSrc=Microsoft.SqlServer.Management.UI.ConfigureWizardErrorSR&EvtID=OraclePublisherValidateFailed&LinkId=20476
Quote:
ADDITIONAL INFORMATION:
Unable to run SQL*PLUS. Make certain that a current version of the Oracle client code is installed at the distributor. For addition information, see SQL Server Error 21617 in Troubleshooting Oracle Publishers in SQL Server Books Online. (Microsoft SQL Server,
Error: 21617)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1600&EvtSrc=MSSQLServer&EvtID=21617&LinkId=20476
Unquote
In fact I can run SQL*PLus from my c:\drive command prompt and the Path in Envinronment variable has set to "c:\app\product\11.2.0\client_1\bin". So I don't know why thing msg prompt?
I have search the guideline on this error in Technet and do what I can to troubleshoot but still got error.
Kindly pls help me.
Thank you.
Avelyn1.Make certain that a current version of the oracle client code is installed at the distributor”, please install corresponding version of Oracle
Client tools on Distributor Box
2.Are you able to connect to your Oracle server from the Distributor Box?if so,Distributor
box needs to have Oracle client tools installed on it before you can setup replication , I hope you have installed the Oracle client tools on Distributor Box. If yes, check if using SQLPlus you can connect manually to Oracle server or not from your Distributor
Box.
Moreover,Please refer the below
Before attempting to configure the Oracle Publisher, SQL Server verifies that SQL*PLUS is accessible through the system path on the Distributor. If SQL*PLUS cannot be loaded, the following error message is shown:
"Unable to run SQL*PLUS. Make certain that a current version of the Oracle client code is installed at the distributor."
Try to locate SQL*PLUS on the Distributor. For an Oracle 10g client install, the name of this executable is sqlplus.exe. It is typically installed in %ORACLE_HOME%/bin. To verify that the path of SQL*PLUS appears in the system path, examine the value of the
system variable Path:
Right-click My Computer, and then click Properties.
Click the Advanced tab, and then click Environment variables.
In the Environment Variables dialog box, in the System variables list, select the Path variable,
and then click Edit.
In the Edit System Variable dialog box: if the path to the folder that contains sqlplus.exe is not present in the Variable
value text box, edit the string to include it.
Click OK on each open dialog box to exit and save changes. -
Source is Oralce. Destination is SQL Server.
Requirement - I have to fetch sql server server data (empid's) based emp table and send this as input data to oracle to fetch and empid's are common.
I cannot use merge or loopkup or for each as oracle have too many records.
For example - In MS SQL - i have empid=1,2..Only these records, I have to fetch from oracle source into sql server destination. For this, I have adopted the below approaches...The major problem I face, when i build a empid's as a string, it is taking only
4000 chars. My string lenght is 10000. How do I breakup this string lengh and send to data flow task till all broken strings length passed to DFT.
Approach-1
created two variables - oraquery string, empid string
step1 - ms sql database - created sql task - declare @empid varchar(max)
SELECT @empid=
Stuff((SELECT ',' + empid
FROM
(SELECT DISTINCT convert(varchar(10),empid ) empid FROM emp
) x
For XML PATH ('')),1,1,'')
select @empid = '(' + @empid + ')'
select @empid
resultset=singlerow
resultset=resultname=0; variablename=User::empid (empid is declared as string)
step2 - oracle database - created data flow task
created oledb source
I put this statemnt in oraquery expression - "select * from dept where dept in "
+ @[User::empid] + "
expression=true
[OLE DB Source [1]] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E14.
An OLE DB record is available. Source: "Microsoft OLE DB Provider for Oracle" Hresult: 0x80040E14 Description: "ORA-00936: missing expression".
Approach-2
created three variables - oraquery string, empid int, loop object--when I put int then it is automatically setting to 0
step1 - ms sql database - created sql task - SELECT DISTINCT convert(varchar(10),empid ) empid FROM emp
resultset=fullresult
resultset=resultname=0; variablename=User::loop
step2 - created a for each loop container
for loop editor - for each ado ennumerator
enumerator configuration - loop
variablemapping - variable=empid;index=0
step3 - oracle database - created data flow task (outside for each loop. If I put inside it is taking long time)
created oledb source
I put this statemnt in oraquery expression - "select * from dept where dept in "
+ @[User::empid] + "
expression=true
Data inserting in a destination table but empid=0.Sorry didnt understand if your step3 is outside loop how
@[User::empid] will get values for the empids from User::loop. The iteration happens inside loop so you
need to have a logic to form the delimited list inside using a script task or something and concatenating everything and storing to variable @[User::empid]
. Then only it will have full value used to be used in step3 query
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Oracle xml DB and text features are not installed
HI,
I installed Sql developer 3.0 ,oracle 11g and jdk 7 on centos 5.when iam running sql developer its showing error message oracle xml DB and text features are not installed.
pls anyone help me out.
thanks
srinivas
Edited by: srinivas on Oct 17, 2011 4:49 AMmay be help you
Re: Connection Error - Oracle XMLDB and Text Features are not installed. -
How to get triggering sql text in a statement trigger
hi,
I need to get sql text that run on the table in statement trigger on that table. I will log sql statements that run on table for a few weeks. I search for it, there is a ORA_SQL_TEXT function but this function is working on event triggers not statement or for each row triggers.
is there any other way to achive that ?You can use AUDIT
http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_4007.htm#i2115972
>
Auditing Queries on a Table: Example To choose auditing for every SQL statement that queries the employees table in the schema hr, issue the following statement:
AUDIT SELECT
ON hr.employees;
To choose auditing for every statement that successfully queries the employees table in the schema hr, issue the following statement:
AUDIT SELECT
ON hr.employees
WHENEVER SUCCESSFUL;
To choose auditing for every statement that queries the employees table in the schema hr and results in an Oracle Database error, issue the following statement:
AUDIT SELECT
ON hr.employees
WHENEVER NOT SUCCESSFUL;
Auditing Inserts and Updates on a Table: Example To choose auditing for every statement that inserts or updates a row in the customers table in the schema oe, issue the following statement:
AUDIT INSERT, UPDATE
ON oe.customers; -
SQL Text in DATABASE VAULT Events
I'm using Audit Vault 10.2.3.2 to collect audit data from a source database 11gR2 (11.2.0.1) protected with Database Vault. The DBAUD collector is collecting all the Database Vault Events, but in all cases the SQL Text column is empty.
The collector seems to be working fine, I've added the collector user to the Oracle Data Dictionary Realm and I've also granted dv_secanalyst to the user.
Are there any aditional steps that have to be done in order to get the SQL Text?
Thanks.In case anybody is interested, this error has been filed as bug 11818022 with Oracle Support.
Thanks. -
What is the data dictionary that stores the SQL text of stored procedures?
I am handling both Oracle 8i on IBM AIX 5L and Oracle9i on SUN Soliars 8 /9.
What is/are the data dictionary tables, or v$ views that store the SQL text of stored procedured and triggers?
Thank you in advance!If the procedures are not wrapped, you can view them in the dba/all/user_source view. Trigger bodies can be seen in dba/all/user_triggers view.
Message was edited by:
Daniel Fink -
How to see SQL TEXT for inactive sessions.
Hi,
I have SID where the session have been completed.I wanna know,what the session has done.
Is there any sessions which has SQL TEXT of inactive sessions.
Thanks.Plz help me.Hi,
As others already suggested, try this SQL below:
select sess.sid,
sess.serial#,
sess.username,
sql_text
from v$sqlarea sqlarea, v$session sess
where sess.prev_hash_value = sqlarea.hash_value
and sess.prev_sql_addr = sqlarea.address
and sess.username is not null
and sess.status='INACTIVE'; Cheers
Legatti
Maybe you are looking for
-
ORA-01720 while trying to grant select on a view
Hi Friends, Iam getting the following error while trying to grant select privilege for the view to SchemaB, i have the view in schemaA. I have used the tables from both the schema for creating the view and iam getting the error on showing a particula
-
Installation of Primavera P6 R8.3
Dear folks, I'm trying to install Primavera P6 R8.3 on my machine with Windows Vista as Operative System (32-bit) The message that I get is this: Component Windows Installer 4.5 has failed to install with the following error message: "Funzione non co
-
Using Apple TV with an external HD
Hello! I have used an apple TV and external HD for movies (all legally purchased) with a PC for years. I recently updated my computer and purchased a MacBook Pro. When using the PC, I could go to itunes-then movies-and alll the titles of my movies
-
Artwork missing... Leopard? or new iMac problem?
Hi, I recently moved all of my music to my new iMac. Then I discovered that not all of my artwork moved over. Many of the albums that had artwork no longer have it. What's even more strange is that my iPod and iPhone have some of the missing artwork,
-
Puzzled by "negative files" in v1.1 "Export as Catalog"
I've been exploring the new features in v.1.1, and have found something I'm puzzled by. When I go to File/Export as Catalog, there is an option called "Export negative files", which will include duplicates of the original image files in the exported