SQL - Basics Flashcards

1
Q

SELECT

A

extracts data from a database

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

UPDATE

A

updates data in a database

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

DELETE

A

deletes data from a database

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

INSERT INTO

A

Inserts new data into a database

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

CREATE DATABASE

A

creates a new database

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

ALTER DATABASE

A

modifies a database

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

CREATE TABLE

A

creates a new table

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

ALTER TABLE

A

modifies a table

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

DROP TABLE

A

deletes a table

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

CREATE INDEX

A

creates an index (search key)

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

DROP INDEX

A

deletes an index

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

SELECT * FROM Customers;

A

Selects all the records in “Customers”
* = select all

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

SELECT DISTINCT Country FROM Customers;

A

Selects only different “countries” from customers.
Note: Without the “DISTINCT” it would have duplicates.
The distinct removes duplicates and only shows a list of different ones.

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

SELECT Count(*) AS DistinctNumber
FROM (SELECT DISTINCT Country FROM Customers);

A

Selects the number of different countries. The “AS” Sets a name for the column. As there is two select features, you need the other one in brackets. “FROM” needs to be before the start of the bracket so we know where we are getting the info from.

Note: If there’s multiple Commands, the others need to be in brackets.

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

SELECT * FROM Customers
WHERE country = ‘Mexico’;

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