Substitution variables
Replacement variables
Prompt variables
Instead-of variables
This feature cannot be implemented through /SQL*Plus.
SELECT book_title FROM books WHERE price between 500 and 900 AND purchase_date < ’21-JAN-2001’ ORDER BY purchase_date;
SELECT book_title FROM books WHERE price IN (500,900) AND purchase_date < ’21-JAN-2001’ ORDER BY purchase date ASC;
SELECT book_title FROM books WHERE price < 500 or > 900 AND purchase_date < ’21-JAN-2001’ ORDER BY purchase date DESC;
SELECT book_title FROM books WHERE (price < 500 OR price > 900) AND purchase_date < ’21-JAN-2001’ ORDER BY purchase date DESC;
ALTER TABLE student_grades ADD FOREIGN KEY (student_id) REFERENCES students(student_id);
ALTER TABLE student_grades ADD CONSTRAINT NAME = student_id_fk FOREIGN KEY (student_id) REFERENCES students(student_id);
ALTER TABLE student_grades ADD CONSTRAINT student_id_fk FOREIGN KEY (student_id) REFERENCES students(student_id);
ALTER TABLE student grades ADD NAMED CONSTRAINT student_id_fk FOREIGN KEY (student_id) REFERENCES students(student_id);
ALTER TABLE student grades ADD NAME student_id_fk FOREIGN KEY (student_id) REFERENCES students(student_id);
ALTER VIEW emp_dept_vu (ADD manager_id NUMBER);
MODIFY VIEW emp_dept_vu (ADD manager_id NUMBER);
ALTER VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employee e, departments d WHERE e.department_id = d.department_id;
MODIFY VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employees e, departments d WHERE e.department_id = d.department_id;
CREATE OR REPLACE VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employees e, departments d WHERE e.department_id = d.department_id;
You must remove the existing view first, and then run the CREATE VIEW command with a new column list to modify a view.
NOT NULL
PRIMARY KEY
FOREIGN KEY
CHECK
UNIQUE
UPDATE new_employees SET name = (Select last_name|| first_name FROM employees Where employee_id =180) WHERE employee_id =180;
UPDATE new_employees SET name = (SELECT last_name||first_name FROM employees) WHERE employee_id =180;
UPDATE new_employees SET name = (SELECT last_name|| first_name FROM employees WHERE employee_id =180) WHERE employee_id =(SELECT employee_id FROM new employees);
UPDATE new_employees SET name = (SELECT last name|| first_name FROM employees WHERE employee_id= (SELECT employee_id FROM new_employees)) WHERE employee_id =180;
CREATE VIEW emp_Vu AS SELECT employee_id, emp_name, department_id FROM employees WHERE mgr_id IN (102, 120);
CREATE VIEW emp_Vu AS SELECT employee_id, emp_name, job_id department_id FROM employees WHERE mgr_id IN (102, 120);
CREATE VIEW emp_Vu AS SELECT department_id, SUM(sal) TOTALSAL FROM employees WHERE mgr_id IN (102, 120) GROUP BY department_id;
CREATE VIEW emp_Vu AS SELECT employee_id, emp_name, job_id, DISTINCT department_id FROM employees;
SELECT AVERAGE(gpa) FROM student_grades WHERE semester_end > ’01-JAN-2000’ and semester end < 31-DEC-2000’;
SELECT COUNT(gpa) FROM student grades WHERE semester_end > ’01-JAN-2000’ and semester end < ’31-DEC-2000’;
SELECT MIN(gpa) FROM student grades WHERE semester_end > ’01-JAN-2000’ and semester end < ’31-DEC-2000’;
SELECT AVG(gpa) FROM student_grades WHERE semester_end BETWEEN ’01-JAN-2000’ and ’31.DEC.2000’;
SELECT SUM(gpa) FROM student grades WHERE semester_end > ’01-JAN-2000’ and semester end < ’31-DEC-2000’;
SELECT MEDIAN(gpa) FROM student_grades WHERE semester end > ’01-JAN-2000’ and semester end < ’31-DEC-2000’;
You can use aggregate functions in any clause of a SELECT statement.
You can use aggregate functions only in the column list of the SELECT clause and in the WHERE clause of a SELECT statement.
You can mix single row columns with aggregate functions in the column list of a SELECT statement by grouping on the single row columns.
You can pass column names, expressions, constants, or functions as parameters to an aggregate function.
You can use aggregate functions on a table, only by grouping the whole table as one single group.
You cannot group the rows of a table by more than one column while using aggregate functions.
Immediately after the SELECT clause
Before the WHERE clause
Before the FROM clause
After the ORDER BY clause
After the WHERE clause
CREATE TABLE EMP (empno NUMBER(4), ename VARCHAR2(35), deptno NUMBER(7,2) NOT NULL, CONSTRAINT emp_deptno_fk FOREIGN KEY deptno REFERENCES dept deptno);
CREATE TABLE EMP (empno NUMBER(4), ename VARCHAR2(35), deptno NUMBER(7,2) CONSTRAINT emp_deptno_fk REFERENCES dept (deptno));
CREATE TABLE EMP (empno NUMBER(4), ename VARCHAR2(35), deptno NUMBER(7,2) NOT NULL, CONSTRAINT emp_deptno_fk REFERENCES dept (deptno) FOREIGN KEY (deptno));
CREATE TABLE EMP (empno NUMBER(4), ename VARCHAR2(35), deptno NUMBER(7,2) FOREIGN KEY CONSTRAINT emp_deptno_fk REFERENCES dept (deptno));
SELECT * FROM employees where salary > (SELECT MIN(salary) FROM employees GROUP BY department_id);
SELECT * FROM employees WHERE salary = (SELECT AVG(salary) FROM employees GROUP BY department_id);
SELECT distinct department_id FROM employees WHERE salary > ANY (SELECT AVG(salary) FROM employees GROUP BY department_id);
SELECT department_id FROM employees WHERE salary > ALL (SELECT AVG(salary) FROM employees GROUP BY department_id);
SELECT last_name FROM employees WHERE salary > ANY (SELECT MAX(salary) FROM employees GROUP BY department_id);
SELECT department_id FROM employees WHERE salary > ALL (SELECT AVG(salary) FROM employees GROUP BY AVG(SALARY));
SELECT &1,
SELECT &1, '&2' FROM &3 WHERE '&last_name = '&4'';
SELECT &1, &2 FROM &3 WHERE last_name = '&4';
SELECT &1, '&2' FROM EMP WHERE last_name = '&4';
The two statements produce identical results.
The second statement returns a syntax error.
There is no need to specify DESC because the results are sorted in descending order by default.
The two statements can be made to produce identical results by adding a column alias for the salary column in the second SQL statement.
The indexed column is declared as NOT NULL.
The indexed columns are used in the FROM clause.
The indexed columns are part of an expression.
The indexed column contains a wide range of values.
SELECT COUNT(*) FROM employees WHERE last_name='Smith';
SELECT COUNT(dept_id) FROM employees WHERE last_name='Smith';
SELECT DISTINCT(COUNT(dept_id)) FROM employees WHERE last_name='Smith';
SELECT COUNT(DISTINCT dept_id) FROM employees WHERE last_name='Smith';
SELECT UNIQUE(dept_id) FROM employees WHERE last_name='Smith';
Creates a view with constraints
Creates a view even if the underlying parent table has constraints
Creates a view in another schema even if you don't have privileges
Creates a view regardless of whether or not the base tables exist
You can join a maximum of two tables through an equijoin.
You can join a maximum of two columns through an equijoin.
You specify an equijoin condition in the SELECT or FROM clauses of a SELECT statement.
To join two tables through an equijoin, the columns in the join condition must be primary key and foreign key columns.
You can join n tables (all having single column primary keys) in a SQL statement by specifying a minimum of n-1 join conditions.
A WHERE clause can be used to restrict both rows and groups.
A WHERE clause can be used to restrict rows only.
A HAVING clause can be used to restrict both rows and groups.
A HAVING clause can be used to restrict groups only.
A WHERE clause CANNOT be used in a query of the query uses a HAVING clause.
A HAVING clause CANNOT be used in subqueries.
At the beginning of the list.
At the end of the list
In the middle of the list.
At the same location they are listed in the unordered table.
At the beginning of the list.
At the end of the list
In the middle of the list.
At the same location they are listed in the unordered table.
The statement calculates the finance charge incorrectly.
The statement calculates the current balance incorrectly.
The statement returns only accounts that have NO previous balance.
The statement returns only accounts that have new purchases, previous balance, and
SELECT TO_DATE(SYSDATE, 'FMDAY, DD Month, YYYY') From dual;
SELECT TO_CHAR(SYSDATE, 'FMDD, DY Month, 'YYY') From dual;
SELECT TO_CHAR(SYSDATE, 'FMDay, DD Month, YYYY') From dual;
SELECT TO_CHAR(SYSDATE, 'FMDY, DDD Month, YYYY') From dual;
SELECT TO_DATE(SYSDATE, 'FMDY, DDD Month, YYYY') From dual;
SUM(start_date)
AVG(start_date)
COUNT(start_date)
AVG(start_date, end_date)
MIN(start_date)
MAXIMUM(start_date)
SINH
TO_NUMBER.
SQRT.
ROUND.
Wait!
Here's an interesting quiz for you.