SQL Flashcards

1
Q

How do you drop a table?

A

DROP TABLE example

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

How do you drop a column?

A

ALTER TABLE example
DROP COLUMN examplecolumn

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

How do you create a table?

A

CREATE TABLE example {
ID int AUTO INCREMENT,
Name varChar(255),
CONSTRAINT example_pk PRIMARY KEY (ID),
City varChar(255)
};

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

How to add columns?

A

ALTER TABLE example
ADD email varchar(255)

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

how to insert rows?

A

INSERT INTO example (id, name) VALUES (id, name)

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

how to update info

A

UPDATE example
SET contactName = “Glen”
WHERE customerID = 1;

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

When and how to use having?

A

use having for arithmetic functions e.g. finding values where the sum of something is greather than an amount

SELECT Count(customers), Country
FROM example
GROUP BY country
HAVING Count(customers) > 5

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