SQL Flashcards

1
Q
How can you retrieve all rows from a database table called TRAINEE including all columns?
Select one:
a. SELECT * FROM TRAINEE
b. SELECT % FROM TRAINEE
c. RETRIEVE ALL FROM TRAINEE
d. SELECT * IN TRAINEE
A

a. SELECT * FROM TRAINEE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you add a column to the table?
Select one:
a. ALTER TABLE table_name ADD column_name datatype
b. CHANGE TABLE table_name ADD column_name datatype
c. ADD COLUMN IN table_name SET column_name datatype
d. ALTER COLUMN column_name SET datatype

A

a. ALTER TABLE table_name ADD column_name datatype

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you add a record to a table?
Select one:
a. SAVE TABLE_NAME VALUES( ___ , ___ , ___ , ___ )
b. INSERT INTO TABLE_NAME VALUES( ___ , ___ , ___ , ___ )
c. UPDATE TABLE_NAME SET ROW VALUES( ___ , ___ , ___ , ___ )
d. PUT INTO TABLE_NAME VALUES( ___ , ___ , ___ , ___ )

A

b. INSERT INTO TABLE_NAME VALUES( ___ , ___ , ___ , ___ )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
How do you drop a table?
Select one:
a. DROP TABLE table_name 
b. DROP TABLE WHERE TABLE = table_name
c. DROP TABLE column_list
d. DROP TABLE
A

a. DROP TABLE table_name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How would use IN and EXIST?
Select one:
a. EXISTS works best for a small finite set of data, whereas IN is better for subqueries
b. IN works best for a small finite set of data, whereas EXISTS is better for subqueries
c. EXISTS returns a boolean if the row exists, where IN returns the table name a row is located in
d. IN is used in queries (i.e. SELECT * IN TABLE_NAME), where EXISTS finds if a table exists

A

b. IN works best for a small finite set of data, whereas EXISTS is better for subqueries

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
If TableA has 100 rows and TableB has 10 rows, how many rows would be retrieved from the following query: SELECT * FROM TableA, TableB
Select one:
a. 100 
b. 1000
c. 10
d. 10000
A

b. 1000

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a cursor?
Select one:
a. A temporary index to place on a table
b. The icon used to point to the buttons on the GUI
c. A pointer to the context area that holds the rows returned by a SQL statement
d. A stored procedure that triggers on a DDL statement

A

c. A pointer to the context area that holds the rows returned by a SQL statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a primary key?
Select one:
a. A column (or columns) that references a column of another table to establish a relationship between rows
b. The identifier for the database
c. A key used to access a secured database table
d. A column or group of columns that uniquely identify a row

A

d. A column or group of columns that uniquely identify a row

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a foreign key?
Select one:
a. A key used to access a secured database table
b. A column or group of columns that uniquely identify a row
c. The identifier for the database
d. A column (or columns) that references a column of another table to establish a relationship between rows

A

d. A column (or columns) that references a column of another table to establish a relationship between rows

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a trigger?
Select one:
a. Stored programs in PL/SQL which are automatically executed or fired when some event occurs
b. Stored programs in ANSI SQL which are automatically executed or fired when some event occurs
c. A block of SQL code that runs on a timer
d. PL/SQL does not support triggers

A

a. Stored programs in PL/SQL which are automatically executed or fired when some event occurs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a view?
Select one:
a. A GUI for accessing data returned by a SQL statement
b. A physical table created by the database based on the result-set of an SQL statement
c. A virtual table based on the result-set of an SQL statement
d. Another name for a table in SQL

A

c. A virtual table based on the result-set of an SQL statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is not a use of the WHERE clause?
Select one:
a. WHERE can be used with UPDATE statements
b. WHERE can be used with DELETE statements
c. WHERE locates which database/schema/table where a row is located
d. WHERE places a restriction on the rows returned by a query

A

c. WHERE locates which database/schema/table where a row is located

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is not true about DELETE, TRUNCATE, and DROP?
Select one:
a. The DELETE command is used to remove rows from a table
b. The DELETE command can use a WHERE clause to restrict the rows deleted
c. The DROP command removes a database from a table
d. TRUNCATE cannot be rolled back and no triggers will be fired

A

c. The DROP command removes a database from a table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is not true about referential integrity?
Select one:
a. A foreign key in any referencing table must always refer to a valid row in the referenced table
b. Oracle supports referential integrity actions, such as DELETE CASCADE and DELETE SET NULL
c. A row that holds a reference to a child record can be deleted before the child record is
d. Ensures that the relationship between two tables remains synchronized during updates and deletes

A

c. A row that holds a reference to a child record can be deleted before the child record is

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the difference between INNER JOIN and OUTER JOIN?
Select one:
a. An outer join will return only the rows that match based on the join predicate
b. An outer join will return all rows in the left table and those that match in the right table
c. Inner join will return only the rows that match based on the join predicate
d. An inner join will return rows that are not common between both table

A

c. Inner join will return only the rows that match based on the join predicate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the difference between MINUS, INTERSECT?
Select one:
a. INTERSECT returns all rows returned the first query. MINUS returns rows returned by the second query
b. MINUS returns only rows returned by both queries. INTERSECT returns only unique rows returned by the first query but not by the second
c. INTERSECT returns duplicate rows from the first table, where MINUS returns duplicate rows from the second
d. INTERSECT returns only rows returned by both queries. MINUS returns only unique rows returned by the first query but not by the second

A

d. INTERSECT returns only rows returned by both queries. MINUS returns only unique rows returned by the first query but not by the second

17
Q

What is the difference between Order By and Group By?
Select one:
a. ORDER BY is used for sorting results, however SQL does not have a GROUP BY statement
b. GROUP BY is used with aggregate functions to group results, however SQL does not have an ORDER BY statement
c. GROUP BY is used for sorting results, whereas ORDER BY is used with aggregate functions to group results
d. ORDER BY is used for sorting results, whereas GROUP BY is used with aggregate functions to group results

A

d. ORDER BY is used for sorting results, whereas GROUP BY is used with aggregate functions to group results

18
Q

What is the difference between scalar functions and aggregate functions?
Select one:
a. Aggregate functions return a single value, and scalar functions return a single value, calculated from values in a column
b. Aggregate functions cannot use a GROUP BY clause
c. Scalar functions return a single value, and aggregate functions return a single value, calculated from values in a column

A

c. Scalar functions return a single value, and aggregate functions return a single value, calculated from values in a column

19
Q

What is the difference between UNION and UNION ALL?
Select one:
a. UNION ALL will join two tables, whereas UNION joins only rows in the tables
b. UNION will join two tables, whereas UNION ALL joins all tables
c. UNION returns only distinct rows, while UNION ALL returns all rows
d. UNION ALL returns only distinct rows, while UNION returns duplicate rows

A

c. UNION returns only distinct rows, while UNION ALL returns all rows

20
Q

What is the difference between WHERE and HAVING?
Select one:
a. HAVING cannot filter results when using aggregate functions. WHERE is only for use with aggregate functions.
b. WHERE cannot filter results when using aggregate functions. HAVING is only for use with aggregate functions.
c. WHERE is used only with scalar functions. HAVING can be used with aggregate functions.
d. HAVING is used only with scalar functions. WHERE can be used with aggregate functions.

A

b. WHERE cannot filter results when using aggregate functions. HAVING is only for use with aggregate functions.

21
Q

What is the purpose of AND and OR?
Select one:
a. They connect multiple tables together to perform a quick join
b. They connect multiple queries together, also known as subqueries
c. They connect multiple columns together to restrict the columns returned in a query
d. They connect multiple WHERE clauses together to restrict results

A

d. They connect multiple WHERE clauses together to restrict results

22
Q
Which is not a constraint in SQL?
Select one:
a. FOREIGN KEY
b. PRIMARY KEY
c. NULL 
d. UNIQUE
A

c. NULL

23
Q
Which is not a join available in SQL?
Select one:
a. LEFT JOIN
b. UNDER JOIN 
c. RIGHT JOIN
d. INNER JOIN
A

b. UNDER JOIN