SQL statements formats n shit Flashcards

1
Q

create table statement

A

CREATE TABLE TableName (
Column1 Datatype1 PRIMARY KEY,
Column2 Datatype2,
Column3 Datatype3
);

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

create views statement

A

CREATE VIEW ViewName AS
SELECT Column1, Column2
FROM TableName
WHERE Condition;

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

joins statement

A

SELECT Table1.Column1, Table2.Column2
FROM Table1
INNER JOIN Table2 ON Table1.ID = Table2.ID;

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

insert… into statement

A

INSERT INTO TableName (Column1, Column2) VALUES (Value1, Value2);

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

update… set statement

A

UPDATE TableName SET Column1 = NewValue WHERE Condition;

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

alter table to add column statement

A

ALTER TABLE TableName ADD ColumnName Datatype;

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

make a foreign key

A

FOREIGN KEY (ForeignColumn) REFERENCES OtherTable(PrimaryKeyColumn)

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

select statement

A

SELECT Column1, Column2 FROM TableName WHERE Condition;

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

adding keys into table statement

A

ALTER TABLE TableName ADD CONSTRAINT[regular syntax]

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