The most basic SQL 1×1

Fortunately I only get in touch with SQL (yeah, this not so Structured Query Language) every other week. Unfortunately until then the pesky syntax details always bite and force me to look them up on the internet, or a nearby old-fashined bookshelf. So here goes the most basic 1×1:

CREATE TABLE table_name (”column1″ “data_type1″, “column2″ “data_type2″, …);

INSERT INTO table_name (”column1″, “column2″, …) VALUES (”value1″, “value2″, …);

UPDATE table_name SET column1=value, column2=value2, … WHERE some_column=some_value …;

SELECT column_name(s or e.g. *) FROM table_name WHERE some_column=some_value …;

DELETE FROM table_name WHERE some_column=some_value;

Update:

SELECT COUNT(*) FROM table_name WHERE some_column = some_value;

Update 2:

ALTER TABLE table_name ADD COLUMN some_column …;

Leave a Reply

You must be logged in to post a comment.