SQL Flashcards
1
Q
How do you drop a table?
A
DROP TABLE example
2
Q
How do you drop a column?
A
ALTER TABLE example
DROP COLUMN examplecolumn
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)
};
4
Q
How to add columns?
A
ALTER TABLE example
ADD email varchar(255)
5
Q
how to insert rows?
A
INSERT INTO example (id, name) VALUES (id, name)
6
Q
how to update info
A
UPDATE example
SET contactName = “Glen”
WHERE customerID = 1;
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