Shared Flashcard Set

Details

SQL Query Basics
Learn the basics of SQL Commands
40
Computer Science
Professional
02/03/2012

Additional Computer Science Flashcards

 


 

Cards

Term
What are the names of the four 'basic' SQL data commands?
Definition
Insert - Select - Update - Delete
Term
What are the four basic data operations you can do using SQL?
Definition
  1. Insert/add new data to a table.
  2. Select/get data from a table or tables.
  3. Update/change data in a table.
  4. Delete/remove data in a table.
Term
What does the Select command do?
Definition
Select gets data from one or more tables in a database.
Term
What does the Insert command do?
Definition
Insert adds a new record to a table.
Term
What does the Delete command do?
Definition
Delete removes a record from the database.
Term
What does the Update command do?
Definition
Update changes existing data in a record.
Term
How many 'databases' can be in a RDBMS system?
Definition
Each RDBMS can hold many different databases all at the same time.
Term
Do 'databases' in an RDBMS know about each other?
Definition
No.  Each 'database' in an RDBMS is self contained and totally seperate then every other.
Term
Given there can be many databases in an RDBMS, how do decide which one to use?
Definition

You must submit the USE command followed by the name of the database.


For example: To use a database named "Bills" you would submit the "USE Bills" command, without the quotes.  This tells the RDBMS you want to work with the Bills database.

Term
Tables live in a _______.
Definition
Tables live in a database.
Term
Databases live in a ________.
Definition
Databases live in a RDBMS or database server.
Term
Tables are made up of _______.
Definition
Tables are made of up of rows and columns.
Term
What is a more technical or proper name for a row in a table?
Definition
Record.
Term

Is this a correct statement: 

Data is stored in a table, tables are stored in a database and databases are stored within an RDBMS or database server?

Definition
Yes that is true.
Term
What is the syntax of the Select command?
Definition

Select (values) From <tableName>


For example: Select * From Vendors 

-or-

Select DatePaid, BillAmount From Bills Where DatePaid = '09/09/12'

Term
What is the syntax of the Delete command?
Definition

DELETE FROM table_name
WHERE some_column=some_value


Example: Delete From Vendors Where VendorName = 'Microsoft'

Term
What is the syntax of the Insert command?
Definition

INSERT INTO table_name (column1, column2, column3,...)
VALUES (value1, value2, value3,...)

 

 

 

 

 

Term
What is the syntax of the Update command?
Definition
UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value
Term
What command do you use to create a new database?
Definition

CREATE DATABASE database_name


This creates a new database inside the RDBMS or database server.

Term

What does these commands do?

Create Database Bills

Use Bills

Create Table Vendors (VendorID char(10), VendorName varchar(30))

Definition
This would create a database in the RDBMS called "Bills" and then you Use the Bills database, to create a table in the Bills database called "Vendors" with two columns.
Term
How do you create a new table in a database?
Definition

CREATE TABLE table_name(
column_name1 data_type,
column_name2 data_type,
column_name3 data_type,....)

 

 

Term
How do you delete a table?
Definition
DROP TABLE table_name
Term
How do you delete a database in the RDBMS?
Definition
Drop Database database_name
Term
What does a Select Where command do?
Definition
It allows you to specify what data you want to get from the database.  
Term
How is a Select different then a Select Where?
Definition

 

They are basically the same commands, just that adding the "where" clause lets you specify what data you want.  Without the "where" clause you get all the data in the system.

 

 

 

 

 

Term
What does a Where clause do?
Definition
A "Where" clause is used with either Select or Delete commands to  specify what data is to be returned.  "Where" means "give me all the data 'where' this is true.   For example: Select FirstName From PhoneBook Where FirstName = "John" would only give you a record set where the FirstName value is "John".
Term
With SQL how would you get the data for a column named "FirstName" and "PhoneNumber" from the Phonebook table?
Definition
Select FirstName, PhoneNumber From Phonebook
Term
How do you get all the records from a table named VendorName?
Definition
Select * From VendorName
Term
How would you get all the Apples in a table named Fruits in a column named FruitName?
Definition
Select * From Fruits Where FruitName = "Apple"
Term
How would you delete all records from the Invoices table, that were paid on '05/06/12' using the datePaid column?
Definition
Delete From Invoices Where datePaid = '05/06/12'
Term
What are the key four types of data?
Definition
  1. Character (string)
  2. Number 
  3. DateTime
  4. Boolean (YES/NO - True/False)
Term
Why would zip code not be a number?
Definition
You don't do math with zip codes.
Term
How do you know if something is really a number and not a string?
Definition
Number values are potentially used for math and strings are not.
Term
What is "database context?"
Definition
The 'database context' simply means what database are you running in currently.  It is the name of the database you are using after issuing the USE command.
Term
If you Delete data from a database can you undo it?
Definition
Not easily.  You must either Insert the data back or restore the data from a backup. You cannot 'undo' a delete.
Term
After you Update data in a database, can you undo the update?
Definition
Not easily.  You can either add the back using another Update command or possibly restore from a backup if you have one.
Term
After you create a database what do you do?
Definition
Create the tables with the proper columns.
Term
After you create a table what do you typically do?
Definition
You populate the table using the Insert command to add new records.
Term
After you Insert, Update or Delete a record how do you check your work?
Definition
You can run a Select command to see  your changes.  
Term

Is this correct:

SQL can be used on any SQL RDBMS, regardless of vendor.

Definition
Yes.  If the RDBMS is a SQL RDBMS.
Supporting users have an ad free experience!