Title: SQL Server 2014 Creating Tables in a Database Tutorial Videos for Beginner
1CATCH EXPERTS
https//www.catchexperts.com
http//www.courseing.com
2SQL Server 2014 Creating Tables in a
Database Tutorial Videos for Beginner by
3Highlights
- Creating a table using Management Studio
- Creating a table using T-SQL
- Creating relationships between tables
4Creating a table using Management Studio
- Creating a table using management studio is as
follows - In SSMS, in Object Explorer, connect to the
instance of Database Engine that contains the
database to be modified. - In Object Explorer, expand the Databases node and
then expand the database that will contain the
new table. - In Object Explorer, right-click the Tables node
of your database and then click New Table.
5Creating a table using Management Studio
- 4. Type column names, choose data types, and
choose whether to allow nulls for each column as
shown in the following illustration. - To specify more properties for a column, such as
identity or computed column values, click the
column and in the column properties tab, choose
the appropriate properties. - To specify a column as a primary key, right-click
the column and select Set Primary Key. - To create foreign key relationships, check
constraints, or indexes, right-click in the
6Creating a table using Management Studio
- Table Designer pane and select an object from the
list. - To specify a different schema for the table,
right-click in the Table Designer pane and
select Properties From the Schema drop-down
list, select the appropriate schema. - From the File menu, choose Save table name.
- In the Choose Name dialog box, type a name for
the table and click OK. - To view the new table, in Object Explorer, expand
the Tables node and press F5 to refresh the list
of objects. The new table is displayed in the
list of tables.
7Creating a table using T-SQL
- Using Query Editor tables can be created in
T-SQL, and creation is as follows - In Object Explorer, connect to an instance of
Database Engine. - On the Standard bar, click New Query.
- Copy and paste the following example into the
query window and click Execute. - Code CREATE TABLE dbo.PurchaseOrderDetail (
PurchaseOrderID int NOT NULL , LineNumber
smallint NOT NULL ,ProductID int NULL ,UnitPrice
money NULL ,OrderQty smallint NULL ,ReceivedQty
float NULL ,RejectedQty float NULL ,DueDate
datetime NULL ) -
-
-
-
8Creating relationships between tables
- Creating a foreign key relationship in Table
Designer using SQL Server Management Studio is as
follows. - In Object Explorer, right-click the table that
will be on the foreign-key side of the
relationship and click Design. The table opens
in Table Designer. - From the Table Designer menu, click Relationships.
- In the Foreign-key Relationships dialog box,
click Add. - The relationship appears in the Selected
Relationship list with a system-provided
9Creating relationships between tables
- name in the format FK_lttablenamegt_lttablenamegt.
- Click the relationship in the Selected
Relationship list. - Click Tables and Columns Specification in the
grid to the right and click the ellipses () to
the right of the property. - In the Tables and Columns dialog box, in
the Primary Key drop-down list, choose the table
that will be on the primary-key side of the
relationship.
10Creating relationships between tables
- Choose OK to create the relationship.
- 9. In the grid beneath, choose the columns
contributing to the table's primary key. In the
adjacent grid cell to the left of each column,
choose the corresponding foreign-key column of
the foreign-key table. - 10. Table Designer suggests a name for the
relationship. To change this name, edit the
contents of the Relationship Name text box.
11Feedback
Like It ? Hate It?
We would love to hear from you whatever you think
about the course.
Click HERE to share what you think!
12Thank you
Thank You for Watching SQL Server 2014 Creating
Tables in a Database Tutorial Videos for
Beginner by
http//www.courseing.com