Skip to main content

18. ADDING CHECK CONSTRAINT WHILE INSERTING.

Examine the structure of the EMPLOYEES table:

EMPLOYEE_ID NUMBER NOT NULL
EMP_NAME VARCHAR2(30)
JOB_ID VARCHAR2(20)
SAL NUMBER
MGR_ID NUMBER
DEPARTMENT_ID NUMBER

You want to create a SQL script file that contains an INSERT statement.
When the script is run, the INSERT statement should insert a row with the specified values into the EMPLOYEES table.
The INSERT statement should pass values to the table columns as specified below:

EMPLOYEE_ID: Next value from the sequence

EMP_ID_SEQEMP_NAME and JOB_ID: As specified by the user during run time, through substitution variables

SAL: 2000

MGR_ID: No value

DEPARTMENT_ID: Supplied by the user during run time throughsubstitutionvariable.

The INSERT statement should fail if the user supplies a value other than20 or 50.

Which INSERT statement meets the above requirements?

A. INSERT INTO employees VALUES (emp_id_seq.NEXTVAL, '&ename', '&jobid', 2000, NULL,&did);

B. INSERT INTO employees VALUES (emp_id_seq.NEXTVAL, '&ename', '&jobid', 2000, NULL,&did IN (20,50));

C. INSERT INTO (SELECT * FROM employees WHERE department_id IN (20,50)) VALUES(emp_id_seq.NEXTVAL, '&ename', '&jobid', 2000, NULL, &did);

D. INSERT INTO (SELECT * FROM employees WHERE department_id IN (20,50) WITH CHECKOPTION) VALUES (emp_id_seq.NEXTVAL, '&ename', '&jobid', 2000, NULL, &did);

E. INSERT INTO (SELECT * FROM employees WHERE (department_id = 20 AND department_id = 50) WITH CHECK OPTION ) VALUES (emp_id_seq.NEXTVAL, '&ename','&jobid', 2000, NULL, &did);

Answer: D

Comments

Popular posts from this blog

Question 8: Aggregate Functions

Examine the description of the STUDENTS table: STD_ID NUMBER(4) COURSE_ID VARCHARD2(10) START_DATE DATE END_DATE DATE Which two aggregate functions are valid on the START_DATE column? (Choose two) A. SUM(start_date) B. AVG(start_date) C. COUNT(start_date) D. AVG(start_date, end_date) E. MIN(start_date) F. MAXIMUM(start_date) Answer: C & E Explanation: It is possible to apply COUNT() and MIN() functions on the column with DATE data type. Incorrect Answers A: Function SUM() cannot be used with DATE data type column. B: Function AVG() cannot be used with DATE data type column. D: Function AVG() cannot be used with DATE data type column, and function AVG() just has one parameter X, not two. It averages all X column values returned by the SELECT statement. F: There is no MAXIMUM() function in Oracle, only MAX() function exists.

19. Oracle Processes

Processes Oracle uses many small (focused) processes to manage and control the Oracle instance. This allows for optimum execution on multi-processor systems using multi-core and multi-threaded technology. Some of these processes include: PMON - Process Monitor SMON - System Monitor ARCn - Redo Log Archiver LGWR - Redo Log Writer DBWn - Database Writer CKPT - Checkpoint process RECO - Recoverer CJQn - Job Queue Coordinator QMNn - Queue-monitor processes Dnnn - Dispatcher Processes (multiplex server-processes on behalf of users) Snnn - Shared server processes (serve client-requests) MMAN - Internal process (used for internal database tasks) LSP0 - Logical standby coordinator process (controls Data Guard log-application) MRP - Media-recovery process (detached recovery-server process) MMON - Memory-monitor process MMNL - Memory monitor light (gathers and stores AWR statistics) PSP0 - Process-spawner (spawns Oracle processes) RFS - Remote file server process (archive to a remote site) DBRM ...

20. TRIM Function

Which SELECT statement will the result 'elloworld' from the string 'HelloWorld'? A. SELECT SUBSTR( 'HelloWorld',1) FROM dual; B. SELECT INITCAP(TRIM ('HelloWorld', 1,1)) FROM dual; C. SELECT LOWER(SUBSTR('HellowWorld', 1, 1) FROM dual; D. SELECT LOWER(SUBSTR('HelloWorld', 2, 1) FROM dual; E. SELECT LOWER(TRIM ('H' FROM 'HelloWorld')) FROM dual; Answer: E Explanation: TRIM function accept a string describing the data you would like to trim from a column value. It can trim from both side of column value i.e. left and right. In the following statement this functionwill trim as SELECT LOWER(TRIM ('+' FROM 'HelloWorld')) FROM dual; From the above statement trim function will remove the character 'H' from 'HelloWorld' and LOWER function will convert the remaining character to lower case.