Day-4
Creating
your first table
- Develop a naming standard.
- Understand schemas.
- Understand the different SQL Server data types.
- Understand column properties.
- Create and alter tables.
- Understand computed columns.
- Add constraints to a table.
- Understand the File Table feature.
- Create a database diagram.
You will create your first table using Microsoft SQL Server
Management Studio (SSMS) and Transact-SQL (T-SQL).
Database is the primary container of all objects on an instance of Microsoft SQL Server, the table is the primary container of all data on a SQL Server instance.
Database is the primary container of all objects on an instance of Microsoft SQL Server, the table is the primary container of all data on a SQL Server instance.
Tables serve as the basic unit of organization for any
database, including those managed by SQL Server 2012. Designing appropriate
tables to store your data is an essential responsibility of a database
developer and both designers and administrators must be familiar with the
process of creating new SQL Server database tables.
Use SQL Server Management Studio. Go ahead and open SSMS and
connect to the server that hosts the database where you would like to create a
new table.
Within SSMS, you'll need to navigate to the Tables folder of
the correct database. Notice that the folder structure on the left side of the
window contains a folder called "Databases". Begin by expanding this
folder. You will then see folders corresponding to each of the databases hosted
on your server. Expand the folder corresponding to the database where you wish
to create a new table.
Finally, expand the Tables folder underneath that database. Take a moment to examine the list of tables that already exist in the database and make sure it reflects your understanding of the existing database structure. You want to be sure not to create a duplicate table, as this will cause you fundamental problems down the road that may be difficult to correct.
Finally, expand the Tables folder underneath that database. Take a moment to examine the list of tables that already exist in the database and make sure it reflects your understanding of the existing database structure. You want to be sure not to create a duplicate table, as this will cause you fundamental problems down the road that may be difficult to correct.
Right click on the Tables folder and select New Table from
the pop-up menu. This will open a new pane within SSMS where you may create
your first database table.
Create Table Columns
The design interface presents you with a three-column grid
to specify the table properties. For each attribute you wish to store in the
table, you will need to identify:
Each database attribute is similar to a variable; it is a
single data item that your database will store for each record. You might have
columns named FirstName, LastName, HomePhone, and EmailAddress containing
information about each person in the contact database.
Data Type: The data type specifies the type of
information that you will store in each column.
Allow Nulls: This is simply a checkbox. If you check
it, the database will allow you to store null (or blank) values in that column.
Primary Key: Next, highlight the column(s) that
you've selected for your table's primary key. Then click the key icon in the
taskbar to set the primary key. If you have a multivalued primary key, use the
CTRL key to highlight multiple rows before clicking the key icon.
Name and Save Your Table: After creating a primary key, use the disk icon
in the toolbar to save your table to the server. You'll be asked to provide a
name for your table when you save it for the first time. Be sure to choose
something descriptive that will help others understand the purpose of the
table.Thanks & Regards
Srikanth Goud- Virtualization Administrator
No comments:
Post a Comment