SQL - Basics Flashcards

Flashcards for aid in learning the basics of SQL Language.

1
Q

What does the DML query/update command SELECT do?

A

Extracts data from a database table.

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

What does the DML query/update command UPDATE do?

A

Updates data in a database table.

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

What does the DML query/update command DELETE do?

A

Deletes data from a database table.

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

What does the DML query/update command INSERT INTO do?

A

Inserts new data into a database table.

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

What does DML stand for?

A

Data Manipulation Language

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

What does the DDL query/update command CREATE TABLE do?

A

Creates a new database table.

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

What does the DDL query/update command ALTER TABLE do?

A

Alters (changes) a database table.

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

What does the DDL query/update command DROP TABLE do?

A

Deletes a database table.

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

What does the DDL query/update command CREATE INDEX do?

A

Creates and index (search key).

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

What does the DDL query/update command DROP INDEX do?

A

Deletes an index.

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

What does DDL stand for?

A

Data Definition Language

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

What does SQL stand for?

A

Structured Query Language

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

What is the syntax for using a select statement?

A
SELECT column_name(s)
FROM table_name
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you select multiple columns using the SELECT statement?

A

Separate the column names with commas. Ex:

SELECT column_name1, column_name2
FROM table_name

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

What is the syntax used to select all columns from a table?

A

SELECT * FROM table_name

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

A semicolon is the standard way to separate each SQL statement in database systems that allow more than one SQL statement to be executed in the same call to the server. Is it necessary to use a semicolon?

A

Not always. It depends on the database program you are using.

17
Q

The result from a SQL query is stored in a ______-___. Most database software systems use programming functions, like: Move-To-First-Record, Get-Record-Content, Move-To-Next-Record, etc. to navigate this with.

A

result-set

18
Q

The DISTINCT keyword is used to return only distinct (different) values. What is the syntax of a SELECT statement with this keyword added to it?

A

SELECT DISTINCT column_name(s)

FROM table_name

19
Q

What is the syntax for using a WHERE clause in a SELECT statement?

A

SELECT column_name FROM table

WHERE column_name value

20
Q

True or False: SQL uses single quotes around text values (most database systems will also accept double quotes). Numeric values however should also be enclosed in quotes.

A

False, numeric values should not be enclosed in quotes.

21
Q

The LIKE condition is used to specify a search for a pattern in a column. What is the syntax of using LIKE in a SELECT statement?

A

SELECT column_name FROM table

WHERE column_name LIKE pattern_type

22
Q

A “%” sign can be used to define wildcards (missing letters in the pattern) both before and after the pattern in a LIKE condition. What would the syntax be for a statement that will return all people with first names that start with an ‘O’ in the table Persons? Assume the table has the following columns: FirstName, LastName and Address

A

SELECT * FROM Persons

WHERE FirstName LIKE ‘O%’

23
Q

A “%” sign can be used to define wildcards (missing letters in the pattern) both before and after the pattern in a LIKE condition. What would the syntax be for a statement that will return all people with first names that contain the letters ‘la’ in them from the table Persons? Assume the table has the following columns: FirstName, LastName and Address

A

SELECT * FROM Persons

WHERE FirstName LIKE ‘%la%’

24
Q

The INSERT INTO statement is used to insert new rows into a table. What is the syntax for using this command?

A

INSERT INTO table_name

VALUES (value1, value2,….)

25
Q

Using INSERT INTO, it is possible to specify which column to insert new data into. What is the syntax for this?

A

INSERT INTO table_name (column_name1, column_name2,…)

VALUES (value1, value2,….)

26
Q

The UPDATE statement is used to modify the data in a table. What is the syntax for this?

A

UPDATE table_name
SET column_name = new_value
WHERE column_name = some_value

27
Q

The DELETE statement is used to delete rows in a table. What is the syntax for this?

A

DELETE FROM table_name

WHERE column_name = some_value