Definition: SQL (Structured Query Language, pronounced as “sequel”, or “S-Q-L”) is a programming language used to query, analyze, and manipulate data from databases.
Basics
CREATE TABLE
creates a new table.INSERT INTO
adds a new row to a table.SELECT
queries data from a table.UPDATE
edits a row in a table.DELETE FROM
deletes rows from a table.ALTER TABLE
changes an existing table. In other words add something to a table.
Let’s dive deeper into each of their syntax.
Create a table
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype
);
Insert into a table
INSERT INTO table_name (column1, column2, column3)
VALUES (value1, 'value2', value3);
Select
SELECT column_name FROM table_name;// OR
SELECT * FROM table_name; -- For all fields in the table
Update
UPDATE table_name
SET column1 = value1
WHERE some_column = some_value;
Delete
DELETE FROM table_name
WHERE column1 = value1;
Alter a table
ALTER TABLE table_name
ADD column_name datatype;
Thank you for reading!
Next up is more about writing queries in SQL…