SQL
Created @December 18, 2023 8:48 PM
Status Open
Updated @February 7, 2024 3:31 PM
SQL 1
, SQL
INTRODUCTION
SQL —> Structured Query Language —> programming language designed to
manage data stored in relational databases used for…
web frameworks
database applications
MANIPULATION
Relational Databases —>
Syntax
-- relational database --> one table
SELECT * FROM celebs;
relational databases —> database that organizes information into one or more
tables
table —> collection of data organized into rows and columns. —> referred to as
relations
EX: celebs
column —> set of data values of a particular type
EX: id, name, age
row —> single record in a table
EX: id = 1, name = Justin Bieber, age = 22
SQL 2
, All data stored in a relational database is of a certain data type
DATA TYPES
INTEGER —> positive or negative whole number
TEXT —> text string
DATE —> date formatted as YYYY-MM-DD
REAL —> decimal value
Statements —>
statement —> text that the database recognizes as a valid command —> end in a
semicolon (;)
Syntax
CREATE TABLE table_name (
column_1 data_type,
column_2 data_type,
column_3 data_type
);
clause —> perform specific tasks in SQL —> referred to as commands
written in capital letters
EX: CREATE TABLE
table_name —> refers to the name of the table that the command is applied to
parameter —> list of columns, data types, or values that are passed to a clause as
an argument
separated with commas
EX: (column_1 data_type, column_2 data_type…) —> the parameter
SQL 3
, structure of SQL statements —> vary
number of lines does not matter
statement can be written all on one line, or split up across multiple lines
Create —>
CREATE statements allow us to create a new table in the database
enclosed by parentheses and ends with a semicolon
Syntax
CREATE TABLE celebs (
id INTEGER,
name TEXT,
age INTEGER
);
-- celebs --> name of the table
-- (id INTEGER, name TEXT, age INTEGER) --> list of parameters defining
-- each column, or attribute in the table and its data type
CREATE TABLE —> clause that creates a new table
id —> first column in the table that stores an INTEGER
name —> second column in the table that stores a TEXT
age —> third column in the table that stores an INTEGER
Insert —>
INSERT statement inserts a new row into a table
INSERT INTO
VALUES
SQL 4
Created @December 18, 2023 8:48 PM
Status Open
Updated @February 7, 2024 3:31 PM
SQL 1
, SQL
INTRODUCTION
SQL —> Structured Query Language —> programming language designed to
manage data stored in relational databases used for…
web frameworks
database applications
MANIPULATION
Relational Databases —>
Syntax
-- relational database --> one table
SELECT * FROM celebs;
relational databases —> database that organizes information into one or more
tables
table —> collection of data organized into rows and columns. —> referred to as
relations
EX: celebs
column —> set of data values of a particular type
EX: id, name, age
row —> single record in a table
EX: id = 1, name = Justin Bieber, age = 22
SQL 2
, All data stored in a relational database is of a certain data type
DATA TYPES
INTEGER —> positive or negative whole number
TEXT —> text string
DATE —> date formatted as YYYY-MM-DD
REAL —> decimal value
Statements —>
statement —> text that the database recognizes as a valid command —> end in a
semicolon (;)
Syntax
CREATE TABLE table_name (
column_1 data_type,
column_2 data_type,
column_3 data_type
);
clause —> perform specific tasks in SQL —> referred to as commands
written in capital letters
EX: CREATE TABLE
table_name —> refers to the name of the table that the command is applied to
parameter —> list of columns, data types, or values that are passed to a clause as
an argument
separated with commas
EX: (column_1 data_type, column_2 data_type…) —> the parameter
SQL 3
, structure of SQL statements —> vary
number of lines does not matter
statement can be written all on one line, or split up across multiple lines
Create —>
CREATE statements allow us to create a new table in the database
enclosed by parentheses and ends with a semicolon
Syntax
CREATE TABLE celebs (
id INTEGER,
name TEXT,
age INTEGER
);
-- celebs --> name of the table
-- (id INTEGER, name TEXT, age INTEGER) --> list of parameters defining
-- each column, or attribute in the table and its data type
CREATE TABLE —> clause that creates a new table
id —> first column in the table that stores an INTEGER
name —> second column in the table that stores a TEXT
age —> third column in the table that stores an INTEGER
Insert —>
INSERT statement inserts a new row into a table
INSERT INTO
VALUES
SQL 4