SQL/Databases Flashcards
1
Q
How do you create a table?
A
CREATE TABLE tablename (
columnname valuetype,
columnname2 valuetype,
);
2
Q
How do you delete a table?
A
DROP TABLE tablename;
Also exists:
DROP TABLE IF EXISTS test;
3
Q
How do you add rows to a table?
A
INSERT INTO tablename VALUES (value,value,value);
for specific columns:
INSERT INTO tablename (columnname, columnname) VALUES (value,value);
To insert Null:
INSERT INTO tablename DEFAULT VALUES;
4
Q
How do you delete rows from a table?
A
DELETE FROM tablename WHERE clause;
5
Q
How do you change existing values in a row?
A
UPDATE tablename SET field1 = somevalue, field2 = somevalue WHERE clause;