SQL/Databases Flashcards

1
Q

How do you create a table?

A

CREATE TABLE tablename (
columnname valuetype,
columnname2 valuetype,
);

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

How do you delete a table?

A

DROP TABLE tablename;

Also exists:

DROP TABLE IF EXISTS test;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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;

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

How do you delete rows from a table?

A

DELETE FROM tablename WHERE clause;

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

How do you change existing values in a row?

A

UPDATE tablename SET field1 = somevalue, field2 = somevalue WHERE clause;

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