Quiz
DB Programming - ORACLE
Crie uma conta grátis para terminar este quiz
Salve seu progresso e veja sua nota final.
Já tem uma conta? Inicie sessão
Perguntas do quiz (33)
1SQL is
- ACase insensitive
- BCase sensitive
2Which option displays all real PL/SQL Packages
- ADBMS_OUTPUT
UTL_FILE
UTL_HTTP - BUTL_OUTPUT
UTL_FILE
UTL_HTTP - CDBMS_OUTPUT
UTL_FILE
DBMS_HTTP
- ADBMS_OUTPUT
3Select the correct syntax
- ASELECT db_name 'Name',
db_age 'Age',
db_height 'Height'
FROM tbl_people - BSELECT db_name "Name",
db_age "Age",
db_height "Height"
FROM tbl_people - CEither is fine
- ASELECT db_name 'Name',
4Select the correct syntax for constants:
- ATBL_NAME CONST VARCHAR2(10) := 'tbl_name';
- BTBL_NAME CONSTANT VARCHAR2(10) := 'tbl_name';
- CTBL_NAME VARCHAR2(10) AS CONST := 'tbl_name';
- DTBL_NAME VARCHAR2(10) AS CONSTANT := 'tbl_name';
5Select which statement is not true?
- ASUBSTR('This is a test', 6)
Result: 'is a test' - BSUBSTR('This is a test', 6, 2)
Result: 'is' - CSUBSTR('TechOnTheNet', -6, 3)
Result: 'The' - DSUBSTR('This is a test', 6)
Result: 'This i'
- ASUBSTR('This is a test', 6)
6Which statement is not true?
- ASUBSTR('abcdefg',3,4)
cdef - BSUBSTR('abcdefg',-5,4)
cdef - CSUBSTR('abcdefg',1,4)
abcde
- ASUBSTR('abcdefg',3,4)
7Which statement is true?
- ANVL(NULL, 50)
Result: NULL - BNVL(NULL, 50)
Result: 50 - CNVL(NULL, 50)
Result: 'NULL'
- ANVL(NULL, 50)
8Select the correct syntax
- AFOR i 1...10
LOOP
..
END LOOP - BFOR i 1..10
LOOP
..
END LOOP - CFOR i in 1..10
LOOP
..
END LOOP
- AFOR i 1...10
9Select CURSOR structure
- ADECLARE
CURSOR c1 is
SELECT name, age, address FROM
tbl_people
WHERE
age > 18;
BEGIN
FOR r1 in c1
LOOP
DBMS_OUTPUT.PUT_LINE(r1.name|| ' ' || r1.age);
END LOOP;
END; - BDECLARE
CURSOR c1 is
SELECT name, age, address FROM
tbl_people
WHERE
age > 18;
BEGIN
FOR r1 in c1
LOOP
DBMS_OUTPUT.PUT_LINE(c1.r1.name|| ' ' || c1.r1.age);
END LOOP;
END; - CDECLARE
CURSOR c1 is
SELECT name, age, address FROM
tbl_people
WHERE
age > 18;
BEGIN
FOR r1 in c1
LOOP
DBMS_OUTPUT.PUT_LINE(c1.name|| ' ' || c1.age);
END LOOP;
END;
- ADECLARE
10EX / IN CURSORS
- AExplicit cursor
When you declare a query in the declaration
section of a block, you create an explicit cursor.
You will generally use an explicit cursor when
you work with multiple records
Implicit cursor
A cursor that is defined for you by the system
eg SELECT…..INTO or any SQL DML statement
INSERT, UPDATE, DELETE - BImplicit cursor
When you declare a query in the declaration
section of a block, you create an implicit cursor.
You will generally use an implicit cursor when
you work with multiple records
Explicit cursor
A cursor that is defined for you by the system
eg SELECT…..INTO or any SQL DML statement
INSERT, UPDATE, DELETE
- AExplicit cursor
11Select correct record structure:
- ADECLARE
TYPE DeptRec IS RECORD (
dept_id dept.deptno%TYPE,
dept_name VARCHAR2(14),
dept_loc VARCHAR2(13),
processed BOOLEAN);
v_dept_rec DeptRec;
BEGIN
..
END; - BDECLARE
TYPE DeptRec IS %ROWTYPE(
dept_id dept.deptno%TYPE,
dept_name VARCHAR2(14),
dept_loc VARCHAR2(13),
processed BOOLEAN);
v_dept_rec DeptRec;
BEGIN
..
END; - CDECLARE
TYPE DeptRec IS RECORD (
dept_id dept.deptno%TYPE,
dept_name VARCHAR2(14),
dept_loc VARCHAR2(13),
processed BOOLEAN);
v_dept_rec %ROWTYPE%DeptRec;
BEGIN
..
END;
- ADECLARE
12How does decode work?
- ADECODE(gender, 'M' || 'Mr', 'F' || 'Mrs', NULL)
- BDECODE(gender, 'M', 'Mr', 'F', 'Mrs', NULL)
- CDECODE(gender, 'M', 'Mr', 'F', 'Mrs')
- DDECODE('M', 'Mr', 'F', 'Mrs', gender)
13What are collections?
- Aa datatype that offers a way to store singly dimensioned arrays in PL*Sql
- Ba datatype that offers a way to store doubly dimensioned arrays in PL*Sql
14What is the visible DBMS result of this query? (assuming it's the 19/06/2016, at 11 in the morning)
DBMS_OUTPUT.PUT_LINE(TRUNC(SYSDATE));- A'19/06/2016'
- B'19/06/2016 11:00:00'
- C'19/JUN/2016 11:00:00'
- D'19/JUN/2016'
- EQuery fails
15How do you define variables in SQL?
- Av_test VARCHAR2(10) := 'Example';
- Bdefine v_test = 'Example'
- Cv_test VARCHAR2(10);
v_test := 'Example';
16Which statement returns only Saturday?
- ASELECT * WHERE
day_of_week_name LIKE '%URDAY' - BSELECT * WHERE
day_of_week_name LIKE 'URDAY%' - CSELECT * WHERE
day_of_week_name LIKE '%SAT' - DSELECT * WHERE
day_of_week_name LIKE '%DAY'
- ASELECT * WHERE
17How do you log something in the server logs?
- Acommon.log()
- BDBMS_OUTPUT.log()
- CFILE_DIRECTORY.LOG()
18What key does oracle use to escape strings?
- A/
- B%
- C\
- D$
19IF / ELSE IF / ELSE structure in oracle
- AIF
...
THEN
...
ELSE IF
...
ELSE
...
END IF - BIF
...
THEN
...
ELSIF
...
ELSE
...
END IF - CIF
...
THEN
...
ELSIF
...
ELSE
...
ENDIF - DIF
...
THEN
...
ELSE IF
...
ELSE
...
ENDIF
- AIF
20Which is the better join method
- ASELECT * FROM fss_transactions trans,
fss_terminal term, fss_merchant m
WHERE
term.terminalid = trans.terminalid AND
term.merchantid = m.merchantid; - BSELECT m.merchantlastname, sum(to_number(trans.TRANSACTIONAMOUNT)) FROM
fss_transactions trans join
fss_terminal term on term.TERMINALID = trans.terminalid
join fss_merchant m on term.merchantid = m.merchantid
GROUP BY m.merchantlastname;
- ASELECT * FROM fss_transactions trans,
21Select the correct result for:
LPAD('Heres a string', 20, 'x')- A<5 white spaces>Heres a string
- BxxxxxHeres a string
- C<6 white spaces>Heres a string
- DxxxxxxHeres a string
22Which statement correctly displays '99999.98727' to 2 decimal places?
- Ato_number(99999.98727, '9999999.99')
- Bto_char(99999.98727, '9999999.99')
- Cto_char(99999.98727, 'f99999.99')
23How do you create and use a SEQUENCE?
- ACreate:
create sequence my_key
start with 1
maxvalue 99999999
increment by 1
Use:
my_key.CURRVAL
my_key.NEXTVAL - BCreate:
create sequence my_key
start in 1
maxvalue 99999999
increment by 1
Use:
my_key.CURRENTVAL
my_key.NEXTVAL - CCreate:
create sequence my_key
start with 1
maxvalue 99999999
increment by 1
Use:
my_key.CURRVALUE
my_key.NEXTVALUE - DCreate:
create sequence my_key
start in 1
maxvalue 99999999
increment by 1
Use:
my_key.CURRENTVALUE
my_key.NEXTVALUE
- ACreate:
24Select correct syntax for creating a procedure
- Acreate or replace procedure prod_name(p_var VARCHAR2(10))
IS
...
BEGIN
...
END - Bcreate or replace procedure prod_name(p_var VARCHAR2)
IS
DECLARE
...
BEGIN
...
END - Ccreate or replace procedure prod_name(p_var VARCHAR2)
IS
...
BEGIN
...
END - Dcreate or replace procedure prod_name(p_var VARCHAR2(10))
IS
DECLARE
...
BEGIN
...
END
- Acreate or replace procedure prod_name(p_var VARCHAR2(10))
25Select correct syntax for creating a function
- Acreate or replace FUNCTION test_function(p_test VARCHAR2)
RETURN VARCHAR2 is
DECLARE
...
BEGIN
...
RETURN 'return this string';
END; - Bcreate or replace FUNCTION test_function(p_test VARCHAR2)
RETURN VARCHAR2 is
...
BEGIN
...
RETURN 'return this string';
END; - Ccreate or replace FUNCTION test_function(p_test VARCHAR2)
RETURN VARCHAR2 is
...
BEGIN
...
END; - Dcreate or replace FUNCTION test_function(p_test VARCHAR2)
RETURN VARCHAR2 is
...
BEGIN
...
END
RETURN 'return this string';
- Acreate or replace FUNCTION test_function(p_test VARCHAR2)
26Which statement declares 'v_test' as an hour before sysdate?
- Av_test := sysdate - 60
- Bv_test := sysdate - 1
- Cv_test := sysdate - 1/24
- Dv_test := sysdate - 1*24
27Which is correct?
- Acreate or replace procedure here_we_go_magic (p_param VARCHAR2 DEFAULT NULL)
... - Bcreate or replace procedure here_we_go_magic (p_param VARCHAR2 DEFAULT IN NULL)
... - Ccreate or replace procedure here_we_go_magic (p_param VARCHAR2(10) DEFAULT IN NULL)
... - Dcreate or replace procedure here_we_go_magic (p_param VARCHAR2(10) DEFAULT NULL)
...
- Acreate or replace procedure here_we_go_magic (p_param VARCHAR2 DEFAULT NULL)
28Where do we put the 'INTO' statement
- ASELECT age INTO v_age
FROM tbl_person; - BSELECT age
FROM tbl_person
INTO v_age; - CSELECT age
FROM tbl_person
WHERE INTO v_age;
- ASELECT age INTO v_age
29What are commits, rollbacks and autonomous transactions
- AAutonomous transaction
A block where the contents are only run once the main transaction is completed
Transaction
A transaction is a logical unit of work
Commit
Save the changes, ran in code
Rollback
Remove changes, run in code - BAutonomous transaction
A block where the main transaction is suspended while the autonomous transaction is performed
Transaction
A transaction is a logical unit of work
Commit
Save the changes, ran in code
Rollback
Remove changes, run in code
- AAutonomous transaction
30How do you display the OTHERS error in the EXCEPTION block in DBMS_OUTPUT?
- AEXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM || ' ' || SQLCODE); - BEXCEPTION
WHERE OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM || ' ' || SQLCODE); - CEXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERR || ' ' || SQLCODE); - DEXCEPTION
WHERE OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERR || ' ' || SQLCODE);
- AEXCEPTION
31What is PRAGMA?
- ACode that is to be executed at compile time
- BCode that is to be executed at run time
- CCode that is to be executed after run time
32Package structure:
- ACREATE PACKAGE test_pack AS
transmit_data;
END test_pack;
CREATE PACKAGE BODY test_pack AS
procedure transmit_data IS
BEGIN
..
END;
END test_pack; - BCREATE PACKAGE test_pack AS
procedure transmit_data;
END test_pack;
CREATE PACKAGE BODY test_pack AS
procedure transmit_data IS
BEGIN
..
END;
END test_pack; - CCREATE PACKAGE test_pack AS
procedure transmit_data;
END test_pack;
CREATE PACKAGE BODY test_pack AS
procedure transmit_data IS
BEGIN
..
END;
END PACKAGE BODY; - DCREATE PACKAGE test_pack AS
transmit_data;
END test_pack;
CREATE PACKAGE BODY test_pack AS
procedure transmit_data IS
BEGIN
..
END;
END PACKAGE BODY;
- ACREATE PACKAGE test_pack AS
33How do you use UTL?
- ADECLARE
v_file UTL_FILE.file_type;
v_buffer VARCHAR2(255);
...
BEGIN
v_file := UTL_FILE.fopen(DIRECTORY, FILENAME, MODE)
...
UTL_FILE.PUT_LINE(v_buffer, 'heres a string')
...
UTL_FILE.GET_LINE(v_buffer, v_file)
...
END; - BDECLARE
v_file UTL_FILE%file_type;
v_buffer VARCHAR2(255);
...
BEGIN
v_file := UTL_FILE.fopen(DIRECTORY, FILENAME, MODE)
...
UTL_FILE.PUT_LINE(v_file, 'heres a string')
...
UTL_FILE.GET_LINE(v_file, v_buffer)
...
END; - CDECLARE
v_file UTL_FILE%file_type;
v_buffer VARCHAR2(255);
...
BEGIN
v_file := UTL_FILE.fopen(DIRECTORY, FILENAME, MODE)
...
UTL_FILE.PUT_LINE(v_buffer, 'heres a string')
...
UTL_FILE.GET_LINE(v_buffer, v_file)
...
END; - DDECLARE
v_file UTL_FILE.file_type;
v_buffer VARCHAR2(255);
...
BEGIN
v_file := UTL_FILE.fopen(DIRECTORY, FILENAME, MODE)
...
UTL_FILE.PUT_LINE(v_file, 'heres a string')
...
UTL_FILE.GET_LINE(v_file, v_buffer)
...
END;
- ADECLARE
Informações
- Descrição
- Quiz sobre DB Programming - ORACLE, criado por mfavento em 19-06-2016.
- Autor
- mfavento
- Idioma
- English
- Visualizações
- 5
- Avaliação
- Ainda sem avaliações Avalie este quiz