SQL Flashcards
(116 cards)
What is DML and what are the corresponding commands?
Data Manipulation Language: INSERT, UPDATE and DELETE
What is DDL and what are the corresponding commands?
Data Definition Language: CREATE, ALTER, COMMENT, DROP, RENAME, TRUNCATE
What is DCL and what are the corresponding commands?
Data Control Language: GRANT, REVOKE
How do you update a certain column value?
UPDATE table SET col =
How to use a ‘ inside string quotes?
q’!Father’s day!’ or
q’[Father’s day]’
How do you insert a new row of data into a table?
INSERT INTO table (col1, col2, col3) VALUES (val1, val2, val3)
or use a subquery instead of VALUES(….)
What is a searched CASE expression?
When the selector is moved in the individual WHEN clauses:
SELECT job_id CASE WHEN job_id = .. THEN .. WHEN job_id = .. THEN .. etc.
What is a relational database?
a collection of relations or two-dimensional tables controlled by the Oracle server.
What are the components of a relational model?
- collections of objects or relations that store data
- a set of operators that can act on the relations to produce other relations
- data integrity for accuracy and consistency
What is the DUAL table?
- automatically created by Oracle database
- one column DUMMY of type VARCHAR(1)
- one row with value x
Useful for computing a constant expression with the SELECT statement
What is the NULL value used for?
Values that are unavailable, unassigned, unknown or inapplicable
When does an alias require double quotation marks in Oracle?
If it is case-sensitive
What is the default display of dates in Oracle?
DD-MON-RR
How do you use the LIKE operator?
% represents zero or more characters
_ represents a single character
eg. WHERE name LIKE ‘_o%’
TRUE AND NULL
NULL
FALSE AND NULL
FALSE
NULL AND NULL
NULL
TRUE OR NULL
TRUE
FALSE OR NULL
NULL
NULL OR NULL
NULL
Give an example of a row limiting clause
OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY;
FETCH FIRST 5 ROWS ONLY;
For MySQL, use LIMIT
When do you use the double &&?
If you want to reuse a variable value without prompting the user each time (use double the first time, then single)
When do you use the DEFINE command?
To create a variable and assign a value to it
What does SET VERIFY ON do?
It forces SQL developer to display the text of a command after it replaces substitution variables with values