Chapter 3 - SQL (Structured Query Language) Flashcards
What are some Characteristics of SQL?
It is not a complete programming language, but rather a data sublanguage.
It was developed by IBM in the late 1970s. Endorsed and adopted by ANSI in 1992
What are the SQL Statement Categories?
Data Definition Language (DDL) - Used to create DB structures
Data Manipulation Language (DML) - Used to query, insert, modify, and delete
SQL/Persistent Stored Modules (SQL/PSM) - Extends SQL by adding procedural programming capabilities
Transaction Control Language (TCL) - Marks transaction boundaries
Data Control Language (DCL) - Grants and revokes DB permissions
How do you Describe the Structure of a Table in MySQL?
Use the DESC statement. Example: “DESC DEPARTMENT”
What does the * mean when Querying?
- means “all”
When using the query “SELECT * FROM ____” you are selecting all applicable data from the relation
What are the basic SQL DDL Statements for Creating Database Structures?
CREATE - creates DB objects
ALTER - Modify the structure and/or characteristics of DB objects
DROP - To delete DB objects
TRUNCATE - Delete table data while keeping the structure
What is the SQL CREATE TABLE statement format?
CREATE TABLE NEW_TABLE_NAME(
ColumnName DataType OptionalColumnConstraints
ColumnName DataType OptionalColumnConstraints
ColumnName DataType OptionalColumnConstraints
What are the Different Data Types available in all DBMS products? (Pg. 146)
Numeric Data Types
Date and Time Data Types
String Data Types
Other Data Types
What are the SQL DML !Statements! that Query Databases and Modify Data in the Tables?
INSERT - Adding data to a relation
UPDATE - Modifying data in a relation
DELETE - Deleting data in a relation
In the SQL Query Framework, what are the 3 Clauses and what do they do?
SQL SELECT - Specifies which columns are to be listed in the query results
SQL FROM - Specifies which tables are to be used in the query
SQL WHERE - Specifies which rows are to be listed in the query results
What is the DISTINCT keyword in a SELECT statement’s effect?
It brings back all specific values in the query
What are some of the SQL Comparison Operators? (Part 1)
<> = is NOT equal to (!= also applicable)
IN = Equal to one of a set of values
NOT IN = Not equal to any of a set of values
BETWEEN = Within a range of numbers
LIKE = Matches a set of characters
IS NULL = Is equal to NULL
What is the ORDER BY clause with DESC/ASC Keywords?
By default, SQL Server sorts in ascending order, so ordering in descending order would be “ORDER BY TableName DESC”
What is the ORDER BY clause with DESC/ASC Keywords?
By default, SQL Server sorts in ascending order, so ordering in descending order would be “ORDER BY TableName DESC”
What are the 3 Options for the SQL Where Clauses?
Compound clauses (Use logical operators such as AND, OR, NOT)
Ranges (Use range of values like <, <=, >=)
Wildcards (Use underscores for each space needed or percent % signs for multiple spaces)
How do you Include or Exclude Rows that contain NULL values?
Use the IS NULL or IS NOT NULL comparison values