SQL statements formats n shit Flashcards
create table statement
CREATE TABLE TableName (
Column1 Datatype1 PRIMARY KEY,
Column2 Datatype2,
Column3 Datatype3
);
create views statement
CREATE VIEW ViewName AS
SELECT Column1, Column2
FROM TableName
WHERE Condition;
joins statement
SELECT Table1.Column1, Table2.Column2
FROM Table1
INNER JOIN Table2 ON Table1.ID = Table2.ID;
insert… into statement
INSERT INTO TableName (Column1, Column2) VALUES (Value1, Value2);
update… set statement
UPDATE TableName SET Column1 = NewValue WHERE Condition;
alter table to add column statement
ALTER TABLE TableName ADD ColumnName Datatype;
make a foreign key
FOREIGN KEY (ForeignColumn) REFERENCES OtherTable(PrimaryKeyColumn)
select statement
SELECT Column1, Column2 FROM TableName WHERE Condition;
adding keys into table statement
ALTER TABLE TableName ADD CONSTRAINT[regular syntax]