Lesson 2 - Introduction to SQL Flashcards
A standard language for storing, manipulating and retrieving data in databases.
SQL!
stands for Structured Query Language
ANSI stands for…?
Bonus Tip: SQL is an ANSI standard
AMERICAN NATIONAL STANDARDS INSTITUTE
for defining the database structure and controlling access to the data.
- CREATE
- DROP
- ALTER
DDL (DATA DEFINTION LANGUAGE)
for retrieving and updating data.
* INSERT INTO
* SELECT
* UPDATE
* DELETE
DML (Database Manipulation System)
creates an object ( a table, for example) in the database.
SQL CREATE STATEMENT
CREATE DATABASE database_name;
deletes an object in the databases usually irretrie
SQL DROP STATEMENT
DROP DATABASE database_name;
modifies the structure an existing object in various ways. For example, adding a column to an existing table.
SQL ALTER STATEMENT
ALTER TABLE table_name;
Each column in a database table is required to have a name and a data type.
SQL BASIC DATA TYPES
SQL String Data Types (3)
CHAR
* VARCHAR
* TEXT
CHAR(size) Fixed length is 0-255. Default is 1.
VARCHAR(size) - variable length is 0-65535 characters.
TEXT - holds a string with a maximum length of 65, 535 bytes.
SQL Numeric Data Types (3)
INT
* FLOAT
* BOOLEAN
Boolean - zero is false, and nonzero is true
SQL Date and Time Data Types (4)
DATE
* DATETIME
* TIME
* YEAR
Date format is YYYY-MM-DD
Time format is hh:mm:ss
used to specify rules for the data in a table.
SQL CONSTRAINTS
SQL Constraints contains the…?
- NOT NULL
- UNIQUE
- PRIMARY KEY
- FOREIGN KEY
- CHECK
- DEFAULT
is used to select data from a database.
SQL SELECT STATEMENT
SELECT*FROM table_name
can be used to return only distinct (different) values.
SQL DISTINCT STATEMENT
SELECT DISTINCT column_name1, column_name2 FROM table_name