UNIT 1-3 Flashcards

(73 cards)

1
Q

SQL includes commands to create database objects such as tables, indexes, and views, as well as commands to define access rights to those database objects.

A

data definition language (DDL):

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

SQL includes commands to insert, update, delete, and retrieve data within the database tables.

A

data manipulation language (DML):

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

You merely command what is to be done; you don’t have to worry about how it is to be done.

A

SQL is a nonprocedural language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

a group of database objects—such as tables and indexes—that are related to each other.

A

Schema

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

They help distinguish the kinds of data that can be stored or processed inside our database objects.

A

Data Types

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Fixed character length data, 1 to 255 characters

A

CHAR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Variable character length data,1 to 2,000 characters.

A

VARCHAR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Numeric data. decimal(9,2)is used to specify numbers with two decimal places and up to nine digits long, including the decimal places. Some RDBMSs permit the use of a MONEY or a CURRENCY data type.

A

Decimal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Integer values only

A

INT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Small integer values only

A

SMALLINT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

formats vary. Commonly accepted formats are: ’DD-MON-YYYY’, ’DD-MON-YY’, ’MM/DD/YYYY’, and ’MM/DD/YY’

A

DATE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

a collection of related data held in a table format within a database. It consists of columns and rows.

A

TABLE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

In ___________ and flat file databases, a table is a set of data elements (values) using a model of vertical columns (identifiable by name) and horizontal rows, the cell being the unit where a row and c.

A

relational databases

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Each _____ type has an associated T-SQL statement format with various implementations.

A

constraint

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

A column or combination of columns whose values uniquely identify each row in the table

A

PRIMARY KEY

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

A column or combination of columns used to establish and enforce a link between the data in two tables

A

FOREIGN KEY

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Ensures that no duplicate values are entered in specific columns that do not participate in a primary key

A

UNIQUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Enforces domain integrity by limiting the values that are accepted by a column

A

CHECK

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Defines column values stored when no value has been assigned

A

DEFAULT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Designates that a column will accept null values

A

Nullability

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

_____ can be used to improve the efficiency of searches and to avoid duplicate column values.

A

indexesCREATE[UNIQUE] INDEX indexname ON tablename(column1[, column2])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

is a function that returns the current system date

A

getdate()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

is a TSQL function that add a particular date interval from a given column or value. Its accepts the following parameters :

A

dateadd()dateadd ([day type such as year, day, hour, minute etc.], [integer value], [column name or date value])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

is a MySQL function that subtracts a particular date interval from a given column or value.

A

date_subdate_sub([column name or date value], INTERVAL [integer value] [day type such as year, day, hour, minute etc.])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Remember the rule of precedence
1. Perform operations within parentheses.2. Perform power operations.3. Perform multiplications and divisions.4. Perform additions and subtractions.
26
We use ___ if both conditions are true, ___ if at least one of the condition and ___ if we want to negate the result of a conditional expression.
AND, OR, NOT
27
ANSI-standard SQL allows the use of _______ in conjunction with the WHERE clause
Special Operators
28
Used to check whether an attribute value is within a range
BETWEENselect * from tbl_food where fd_price between 10 and 100;
29
Used to check whether an attribute value is null
IS NULLselect * from tbl_food where fd_name is null;
30
Used to check whether an attribute value matches a given string pattern
LIKE
31
Used to check whether an attribute value matches any value within a value list
INselect * from tbl_food where fd_name = 'choco' or fd_name = 'mocha'; can be handled more efficiently with:/*SQL Server and MySQL*/select * from tbl_foodwhere fd_name in ('choco','mocha'); Take note however that if you are using a LARGE list, IN operator tends to be slow.)
32
Used to check whether a subquery returns any rows
EXISTS
33
means any single character NOT within a range or a set.
REGEXP [^]
34
means any single character within a range or a set.
REGEXP[]
35
The _______ command can also be used to add table constraints.
ALTER TABLEALTER TABLE tablenameADD constraint [ ADD constraint] ;
36
You could also use the ALTER TABLE command to remove a column or table constraint.
ALTER TABLE tablenameDROP{PRIMARY KEY|COLUMN columnname |CONSTRAINT constraintname}
37
You can alter an existing table by adding one or more columns.
alter table tbl_productadd p_salecode char(1)
38
We can change a column definition as long as there is either no data or the existing column fits into the new column definition.
// SQL Serveralter table table_namealter column column_name datatype; // MySQLalter table table_namemodify column column_name datatype;
39
If we want to change the size of column pt_name in table tbl_part from varchar(500) to varchar(250)
// SQL Serveralter table tbl_partalter column pt_name varchar(250);// MySQLalter table tbl_partmodify column pt_name varchar(250);
40
Occasionally, you might want to modify a table by deleting a column. Suppose that you want to delete the V_ORDER attribute from the VENDOR table.
alter table tbl_vendordrop column v_order
41
To define the primary key for the table tbl_part, use the following command:
ALTER TABLE [table_name]ADD PRIMARY KEY ([column_name])ALTER TABLE [table_name]ADD FOREIGN KEY ([column_name]) REFERENCES [main_table] ([column_name]) [optional on delete/update cascade]
42
The_____ clause is especially useful when the listing order is important to you
ORDER BYselect columnlistfrom tablelist[where conditionlist][order by columnlist [asc|desc]]
43
SQL’s _____ clause produces a list of only those values that are different from one another
DISTINCTselect distinct v_codefrom tbl_product;
44
Creates a database schema
CREATE SCHEMA AUTHORIZATION
45
Creates a new table in the user's database schema
CREATE TABLE
46
Ensures that a column will not have null values
NOT NULL
47
Ensures that a column will not have duplicate values
UNIQUE
48
Defines a default value for a column (when no value is given)
DEFAULT
49
Validates data in an attribute
CHECK
50
Creates an index for a table
CREATE INDEX
51
Creates a dynamic subset of rows/columns from one or more tables
CREATE VIEW
52
Modifies a table definition (adds, modifies, or deletes attributes or constraints)
ALTER TABLE
53
Creates a new table based on a query in the user's database schema
CREATE TABLE AS
54
Permanently deletes a table (and its data)
DROP TABLE
55
Permanently deletes an index
DROP INDEX
56
Permanently deletes a view
DROP VIEW
57
COMPARISON OPERATORS
= < > <= >= <>
58
LOGICAL OPERATORS
AND OR NOT
59
SPECIAL OPERATORS
BETWEENIS NULLLIKEINEXISTSDISTINCT
60
AGGREGATE FUNCTIONS
COUNTMINMAXSUMAVG
61
Restricts the selection of grouped rows based on a condition
HAVING
62
Orders the selected rows based on one or more attributes
ORDER BY
63
Modifies an attribute's values in one or more table's rows
UPDATE
64
Restricts the selection of rows based on a conditional expression
WHERE
65
Groups the selected rows based on one or more attributes
GROUP BY
66
Deletes one or more rows from a table
DELETE
67
Permanently saves data changes
COMMIT
68
Restores data to their original values
ROLLBACK
69
Checks whether an attribute value matches any value within a value list
IN
70
Returns the number of rows with non-null values for a given column
COUNT
71
Checks whether a subquery returns any rows
ECISTS
72
Limits values to unique values
DISTINCT
73
Checks whether an attribute value matches any given string pattern
LIKE