My Addition Flashcards
In refernce of ALTER TABLE statements
- What is the syntax for
ADD
?
2 As in add column ColumnName
.
- As in include
DataType
ALTER TABLE TableName ADD ColumnName DataType;
In refernce of ALTER TABLE statements
- What is the syntax for
CHANGE
? - As in change a column
CurrentColumnName
toNewColumnName
.
ALTER TABLE TableName CHANGE CurrentColumnName NewColumnName NewDataType;
In refernce of ALTER TABLE statements
- What is the syntax for
DROP
? - As in
DROP ColumnName
ALTER TABLE TableName DROP ColumnName;
What is the definition of tables in relational databases?
Tables are the core structure in relational databases containing a fixed sequence of columns and a varying set of rows.
Each column has a name and a specific data type, while each row consists of values that correspond to the column’s data types.
What are the components of a table?
- A table must have at least one column and can have multiple rows.
- A table can also be empty (having no rows).
Each column has a name and a specific data type.
How do databases handle duplicate rows?
Some databases may allow duplicate rows temporarily, particularly when loading external data into a temporary table.
What SQL statement is used to define a new table?
CREATE TABLE
This statement specifies table names and data types.
What does the DROP TABLE statement do?
Deletes a table and all its data.
What is the purpose of the ALTER TABLE statement?
Used to modify an existing table by adding, changing, or deleting columns.
List common data types used in tables.
- integers (INT)
- values with 0 to N characters (VARCHAR(N))
- dates (DATE)
- decimals (DECIMAL)
What rule governs the values in a cell of a table?
Exactly one value per cell.
Are duplicate column names allowed in a table?
No; duplicate column names are not allowed within the same table but are allowed in different tables.
What principle allows for optimization of storage in tables?
No significant row order
supporting the principle of data independence.
What does it mean that there can be no duplicate rows in a table?
No two rows in a table may have identical values across all columns.
What is a NULL value in a table?
Represents the absence of data in a cell.
- What is the SQL syntax for creating a table
TableName
? - As in with the
Column$
&Data_Type
.
CREATE TABLE TableName (Column1 DATA_TYPE, Column2 DATA_TYPE, ..., ColumnN DATA_TYPE);
Fill in the blank: The ID column is of data type _______.
Integer (INT)
What data type is used for the Name
column with a max 40 characters?
Variable-length string with maximum 40 characters (VARCHAR(40)).
What is the appropriate data type for the ProductType
column?
Variable-length string with maximum 3 characters (VARCHAR(3)).
What data type is used to store dates in a table?
Date
What is the format for the Weight
column data type?
Decimal number with six significant digits and one digit after the decimal point (DECIMAL(6,1))
.
True or False: A table can have multiple rows with identical data.
False.
Why are integers commonly used for IDs in databases?
They allow for efficient storage and quick retrieval when querying for specific products.
What is the advantage of using VARCHAR
for the Name
column?
It allows for variable-length strings, using only the necessary space for each entry.