Tables and Schemas Flashcards
How many databases does a SQL Server table belong to?
Just 1
SQL Server 70-461 08-01
What is meant by base tables?
Based tables hold the core data and are permanent in the sense that if SQL Server is shut down and restarted the based tables contents and definitions would remain.
SQL Server 70-461 08-01
What are two ways you can create a table?
- CREATE TABLE statement
- SELECT INTO statement
SQL Server 70-461 08-01
What is a schema?
A container that holds tables, views, procedures and other database objects.
SQL Server 70-461 08-01
What are two benefits of schemas?
- They allow you to group together objects in a way that makes sense for you and your organization
- You can set permissions at the schema level
SQL Server 70-461 08-01
How many schemas can a particular table belong to?
- Only one. You may have copies of the same table in multiple schemas but you couldn’t update table1 in schema ABC and expect the changes to flow to table1 schema xyz.
- Schema ABC is part of table1’s name and makes it unique to that schema.
SQL Server 70-461 08-01
If you don’t supply a database schema name, what is the default?
The database user name’s default schema
SQL Server 70-461 08-01
Can 2 objects within the same schema have the same name?
For example,
View=Test1
Table=Test1
No. Objects within a schema must have unique names, even if they are different types of objects.
SQL Server 70-461 08-01
How many owners does a schema have?
- Just one authorized database user.
- The schema owner can grant permissions to other users regarding objects in that schema
SQL Server 70-461 08-01
Should you use ROWVERSION OR TIMESTAMP?
ROWVERSION
SQL Server 70-461 08-01
How can you specify whether a column allows nulls?
- By putting NULL or NOT NULL after the columns data type. Null meaning Null’s are allowed.
- Example: categoryname NVARCHAR(15) NOT NULL
SQL Server 70-461 08-01
What two things can you specify when using the identity property?
- Seed=the value to begin with
- Increment=the amount to increase each new sequence number by
- Example: categoryid INT IDENTITY(1,1) NOT NULL
SQL Server 70-461 08-01
What does it mean to make a computed column persisted?
SQL Server will store the computed values with the table’s data and not compute them on the fly.
SQL Server 70-461 08-01
What type of functions can’t be used as part of the computed column expression if the column is persisted?
- Functions that are not deterministic
-
Example:
GETDATE()
CURRENT_TIMESTAMP
SQL Server 70-461 08-01
What does table compression do?
It compresses data in a table, in addition to the indexes, to get more efficient storage.
SQL Server 70-461 08-01
What are the two types of table compression?
- Row
- Page
SQL Server 70-461 08-01
How does row-level compression work?
SQL Server applies a more compact storage format to each row of a table.
SQL Server 70-461 08-01
How does page-level compression work?
It includes row-level compression plus additional compression algorithms that can be performed at the page level.
SQL Server 70-461 08-01
What are 5 variations on tables?
- Temporary Tables
- Table Variables
- Views
- Indexed Views
- Derived Tables and Table Expressions
SQL Server 70-461 08-01
Can you have a schema within another schema?
No
SQL Server 70-461 08-01
What are the 4 built in schemas that can’t be dropped?
- dbo
- guest
- INFORMATION_SCHEMA
- sys
SQL Server 70-461 08-01
What is the general form of the statement to create a schema and assign an owner?
CREATE SCHEMA schema_name AUTHORIZATION user_name
SQL Server 70-461 08-01
What is the general form of a statement to move a table from one schema to another?
ALTER SCHEMA schema_name TRANSFER schema_name.table_name
- ALTER SCHEMA schema_name is the schema you are moving to
- schema_name.table_name is the object to move
- This will work assuming the object with the same does not already exist in the schema you’re transferring to.
SQL Server 70-461 08-01
How can you indicate a specific value to be used in place of a null? (In create table statement)
Add the DEFAULT clause right after NOT NULL
Example:
description NVARCHAR(200) NOT NULL DEFAULT(‘ ‘)
SQL Server 70-461 08-01