Manipulation Flashcards
What does SQL stand for?
Structured Query Language
What are relational databases?
A database that organizes info into one or more tables.
What’s a table?
A collection of data values organized into rows and columns.
What’s a column?
A set of data values of a particular type (id, name, age).
What’s a row?
A single record in a table.
What’s a statement?
Text that the database recognizes as a valid command. Statements always end in a semicolon ;
What’s a clause?
Performs a specific task in SQL. Written in capital letters. Also referred to as a command. (SELECT, CREATE TABLE)
What’s a parameter?
A list of columns, data types, or values that are passed to a clause as an argument.
CREATE
CREATE TABLE celebs ( id INTEGER, name TEXT, age INTEGER );
INSERT
INSERT INTO celebs (id, name, age)
VALUES (1, ‘Justin Bieber’, 22);
SELECT
SELECT name FROM celebs;
will return all data in the name column from the table
SELECT * FROM celebs;
will return every column in the table
ALTER
ALTER TABLE celebs
ADD COLUMN twitter_handle TEXT;
UPDATE
UPDATE celebs
SET twitter_handle = ‘@taylorswift13’
WHERE id = 4;
DELETE
DELETE FROM celebs
WHERE name IS ‘Taylor Swift’;
will remove Taylor Swift from the table.
WHERE twitter_handle IS NULL;
IS NULL is a condition in SQL that returns true when the value is NULL and false otherwise.
What are constraints?
Constraints that add info about how a column can be used are invoked after specifying the data type for a column.
CREATE TABLE awards ( id INTEGER PRIMARY KEY, recipient TEXT NOT NULL, award_name TEXT DEFAULT 'Grammy' );