Friday, 23 February 2018
How to use SQL Tuning Advisor in Oracle SQL Developer?
Oracle SQL Developer -> Connections -> Right mouse click on desired database connection name (e.g. XE) -> Click "Open SQL Worksheet" -> Input and select SQL code block -> Right mouse click then select "SQL Tuning Advisor" or press "CTRL+F12" -> Lastly, analyze the result.
Labels:
oracle sql developer,
SQL Tuning Advisor
How to take screenshot on top window quickly?
e.g.
Alt key + Print Screen key -> Then CTRL + V in "mspaint.exe" -> Save it.
Alt key + Print Screen key -> Then CTRL + V in "mspaint.exe" -> Save it.
Labels:
screenshot,
windows
How to see both Oracle VM Virtual Box 32bit/64bit options?
e.g. If there are only 32 bit Linux distro in the OS list, you should enable virtualization support in BIOS
* BIOS -> CMOS Setup Utility -> Virtualization Technology -> [Enabled]
* BIOS -> CMOS Setup Utility -> Virtualization Technology -> [Enabled]
Labels:
bios,
linux,
oracle,
oracle virtual box
Friday, 16 February 2018
e.g. bulk insert
SET TIMING ON
/
CREATE TABLE HR.EMPLOYEES_TEST
AS
SELECT *
FROM HR.EMPLOYEES
WHERE ROWNUM < 0;
/
DECLARE
TYPE TABLE_TYP IS TABLE OF HR.EMPLOYEES%ROWTYPE;
TABLE_ROWS TABLE_TYP := TABLE_TYP ();
CURSOR TEST_CURSOR
IS
SELECT * FROM HR.EMPLOYEES;
V_COUNT NUMBER;
BEGIN
SELECT COUNT (1) INTO V_COUNT FROM HR.EMPLOYEES;
DBMS_OUTPUT.PUT_LINE ('TOTAL NUMBER OF ROWS: ' || V_COUNT);
OPEN TEST_CURSOR;
LOOP
FETCH TEST_CURSOR BULK COLLECT INTO TABLE_ROWS LIMIT 10;
FORALL A IN TABLE_ROWS.FIRST .. TABLE_ROWS.LAST
INSERT INTO HR.EMPLOYEES_TEST
VALUES TABLE_ROWS (A);
COMMIT;
DBMS_OUTPUT.PUT_LINE (
'Looping, TEST_CURSOR%rowcount = ' || TEST_CURSOR%ROWCOUNT);
EXIT WHEN TEST_CURSOR%NOTFOUND;
--EXIT WHEN TEST_CURSOR%ROWCOUNT > 1000000;
END LOOP;
DBMS_OUTPUT.PUT_LINE (
'Exited, TEST_CURSOR%rowcount = ' || TEST_CURSOR%ROWCOUNT);
CLOSE TEST_CURSOR;
END;
/
/
CREATE TABLE HR.EMPLOYEES_TEST
AS
SELECT *
FROM HR.EMPLOYEES
WHERE ROWNUM < 0;
/
DECLARE
TYPE TABLE_TYP IS TABLE OF HR.EMPLOYEES%ROWTYPE;
TABLE_ROWS TABLE_TYP := TABLE_TYP ();
CURSOR TEST_CURSOR
IS
SELECT * FROM HR.EMPLOYEES;
V_COUNT NUMBER;
BEGIN
SELECT COUNT (1) INTO V_COUNT FROM HR.EMPLOYEES;
DBMS_OUTPUT.PUT_LINE ('TOTAL NUMBER OF ROWS: ' || V_COUNT);
OPEN TEST_CURSOR;
LOOP
FETCH TEST_CURSOR BULK COLLECT INTO TABLE_ROWS LIMIT 10;
FORALL A IN TABLE_ROWS.FIRST .. TABLE_ROWS.LAST
INSERT INTO HR.EMPLOYEES_TEST
VALUES TABLE_ROWS (A);
COMMIT;
DBMS_OUTPUT.PUT_LINE (
'Looping, TEST_CURSOR%rowcount = ' || TEST_CURSOR%ROWCOUNT);
EXIT WHEN TEST_CURSOR%NOTFOUND;
--EXIT WHEN TEST_CURSOR%ROWCOUNT > 1000000;
END LOOP;
DBMS_OUTPUT.PUT_LINE (
'Exited, TEST_CURSOR%rowcount = ' || TEST_CURSOR%ROWCOUNT);
CLOSE TEST_CURSOR;
END;
/
Labels:
bulk insert,
oracle
[ADVICE] Free Database Monitoring Tool
You may use following free tool instead of Oracle EM (Enterprise Manager)
- ASH Viewer (Active Session History)
Labels:
ash viewer,
enterprise manager,
oracle
Friday, 9 February 2018
Naming conventions for database objects
index -> [SHORT_TABLE_NAME]_[SHORT_COLUMN_NAME]_[INDEX_TYPE]
e.g. EMP_DEPARTMENT_IX
constraint -> [SHORT_TABLE_NAME]_[SHORT_COLUMN_NAME]_[CONSTRAINT_TYPE]
e.g.
NOT NULL const. -> EMP_EMAIL_NN
FOREIGN KEY (Referential Integrity) const.
Source table: EMPLOYEES
Column name of source table: DEPARTMENT_ID
-> EMP_DEPT_FK
trigger -> [TABLE_NAME]_TRG
e.g. HR.EMPLOYEES_TRG
sequence -> [TABLE_NAME]_SEQ
e.g. HR.EMPLOYEES_SEQ
type -> [TABLE_NAME]_TYP
e.g. HR.EMPLOYEES_TYP
e.g. EMP_DEPARTMENT_IX
constraint -> [SHORT_TABLE_NAME]_[SHORT_COLUMN_NAME]_[CONSTRAINT_TYPE]
e.g.
NOT NULL const. -> EMP_EMAIL_NN
FOREIGN KEY (Referential Integrity) const.
Source table: EMPLOYEES
Column name of source table: DEPARTMENT_ID
-> EMP_DEPT_FK
trigger -> [TABLE_NAME]_TRG
e.g. HR.EMPLOYEES_TRG
sequence -> [TABLE_NAME]_SEQ
e.g. HR.EMPLOYEES_SEQ
type -> [TABLE_NAME]_TYP
e.g. HR.EMPLOYEES_TYP
Labels:
db objects,
name format,
oracle
Friday, 2 February 2018
How to debug code in Toad?
e.g.
Toad for Oracle -> Database -> Schema Browser -> Click HR -> Click Procedures -> Double click to "PROC_EXEC" procedure -> Set breakpoint or Add Watch (optional) -> Press Shift+F7 or Click Debug-Trace Into -> Confirm -> Click Execute
Toad for Oracle -> Database -> Schema Browser -> Click HR -> Click Procedures -> Double click to "PROC_EXEC" procedure -> Set breakpoint or Add Watch (optional) -> Press Shift+F7 or Click Debug-Trace Into -> Confirm -> Click Execute
How to grap and drop table columns in Toad?
e.g.
Toad for Oracle -> Type HR.EMPLOYEES then Press F4 in Editor -> Select desired columns by CTRL key-> Drag and drop to Editor by mouse -> Columns should show in Editor
Toad for Oracle -> Type HR.EMPLOYEES then Press F4 in Editor -> Select desired columns by CTRL key-> Drag and drop to Editor by mouse -> Columns should show in Editor
Labels:
drag and drop,
toad
Subscribe to:
Posts (Atom)