Database Reference
In-Depth Information
of all the employees. Columns map to attributes from your logical model,
and, like the logical model, each column has a data type assigned. Later in
this chapter we look at the SQL Server data types in detail.
When you add data to a table, each column must either contain data
(even if it is an empty string) or specify a NULL value, NULL being the
complete absence of data. Additionally, you can specify that each column
have a default value. The default value is used if you add data without
specifying a value for that column. A default can be a fixed value, such as
always setting a numeric column to the value of 12, or it can be a function
that returns a value of the appropriate data type. If you do not have a de-
fault value specified and you insert data without specifying a value for a
column, SQL Server attempts to insert a NULL value. If the column does
not allow NULL values, your insert will fail.
You can think of a table as a single spreadsheet in an application such
as Microsoft Excel. In fact, an Excel spreadsheet is a table, but Excel is not
a relational database management system. A database is really nothing
more than a collection of tables that store information. Sure, there are
many other objects in a database, but without tables you would not have
any data. Using Transact-SQL, also known as T-SQL, you can manipulate
the data in a table. The four basic Data Manipulation Language (DML)
statements are defined as follows:
SELECT: Allows users to retrieve data in a table or tables
INSERT: Allows users to add data to a table
UPDATE: Allows users to change data in a table
DELETE: Allows users to remove data from a table
How SQL Server Stores Tables
In addition to understanding what tables are, it's important that you un-
derstand how SQL Server stores them; the type of data your columns store
will dictate how the table is stored on disk, and this can directly affect the
performance of your database. Everything in SQL Server is stored on
pages . Pages are 8K contiguous allocations of information on the disk, and
there are different kinds of pages depending on what is on the page. For
our purposes, we will focus on data pages : pages that store table data.
Each row you add to a table is stored on a page, and depending on the size
of the data in the row, the row can be stored either on a page with other
rows, or on its own page or pages.
Search WWH ::




Custom Search