Structured Query Language (SQL)
is a high-level computer language for storing, manipulating, and retrieving data in a relational database
SQL
... [Show More] commands can create databases and tables.
True or False
True
In the animation above, SQL commands create a database called World and then create three tables for the World database.
A database designer and database user both use SQL.
True
False
True
The database designer uses SQL to create the database and tables, and the database user uses SQL to insert, retrieve, update, and delete data from the tables.
All database systems use identical SQL statements.
True
False
False
The SQL language has been standardized, but SQL implementations can vary between database systems in small ways.
SQL statement
is a complete command composed of one or more clauses
clause
groups SQL keywords like SELECT, FROM, and WHERE with table names like City, column names like Name, and conditions like Population > 100000
Literals
Explicit values that are string, numeric, or binary. Strings must be surrounded by single quotes or double quotes. Binary values are represented with x'0' where the 0 is any hex value.
Ex: 'String' "String" 123 x'0fa2'
Keywords
Words with special meaning.
Ex: SELECT, FROM, WHERE
Identifiers
Objects from the database like tables, columns, etc.
Ex: City, Name, Population
Comments
Statement intended only for humans and ignored by the database when parsing an SQL statement.
Ex: -- single line comment / multi-line Comment /
The INSERT statement adds a student to the Student table. How many clauses are in the INSERT statement?
INSERT INTO Student VALUES (888, 'Smith', 'Jim', 3.0);
1
2
3
2
The INSERT INTO clause is followed by the VALUES clause.
The SQL statement below is used to select students with the last name "Smith". What is wrong with the statement?
SELECT FirstName FROM Student WHERE LastName = Smith;
a. The literal "Smith" must be surrounded by single quotes or double quotes.
b. The WHERE clause should be removed.
c. The last name "Smith" may not exist in the database.
a.
'Single' or "double" quotes must surround string literals.
What is wrong with the SQL statement below?
SELECT FirstName from Student
a. The keyword from must be written FROM.
b. The WHERE clause is missing.
c. A terminating semicolon is missing.
c.
The double dashes preceding the FROM clause cause the database to ignore the FROM clause. The FROM clause is required in a SELECT statement
Which statement shows all databases in a database system?
SHOW TABLES;
SHOW DATABASES;
SHOW COLUMNS;
SHOW TABLES
Which statement shows all tables in the database petStore?
SHOW TABLES;
SHOW TABLES FROM petStore;
SHOW DATABASES;
SHOW TABLES;
Which statement must precede a SHOW TABLES statement to see the tables from the bikeStore database?
SHOW DATABASES;
USE bikeStore;
SHOW COLUMNS FROM bikeStore;
USE bikeStore;
Which statement shows all the columns in the Country table?
SHOW COLUMNS;
SHOW COLUMNS Country;
SHOW COLUMNS FROM Country;
SHOW COLUMNS FROM Country;
Storing a city's population, which ranges from a dozen to 24 million people.
unsigned MEDIUMINT
unsigned INTEGER
unsigned BIGINT
unsigned INTEGER
Storing the annual gain or loss in a city's population, which ranges from -1 million to 1 million.
signed SMALLINT
unsigned MEDIUMINT
signed MEDIUMINT
signed MEDIUMINT
Storing the price of an item that ranges from a few dollars to a few hundred dollars.
FLOAT
DECIMAL(2,5)
DECIMAL(5,2)
DECIMAL(5,2)
Storing the date and time an item is purchased.
DATE
TIME
DATETIME
DATETIME
Storing a student's assigned letter grade, like A or D.
TINYINT
CHAR(1)
VARCHAR(1)
CHAR(1)
Storing a student's email address.
VARCHAR(100)
VARCHAR(10)
CHAR(100)
VARCHAR(100)
Storing a yes or no value.
TINYINT
CHAR(3)
VARCHAR(3)
TINYINT
The Employee table is created with 4 columns.
True
False
true
The ID column only holds non-negative integers.
True
False
true [Show Less]