Lab No. 03
Lab No. 03
03 DATE: 05/09/2023
HOW TO CREATE TABLE IN MS SQL SERVER
Lab outcomes:
After completing this lab, students will be able to:
Know about Microsoft SQL server
Know about SQL server management studio
Create table in SQL server
SOFTWARE REQUIRED:
Microsoft SQL server
SQL server management studio
Theory:
In Microsoft SQL Server, a database table is a structured object that stores data in a tabular
format. Tables are the fundamental building blocks of a relational database system, and they
play a crucial role in organizing and storing data efficiently. In this lab, you will learn how to
create tables in MS SQL Server, define their structure, and set constraints to ensure data
integrity.
Table Structure:
Before you create a table, it's essential to understand the structure of a table and its
components:
1. Table Name: Each table in SQL Server must have a unique name within the
database. The table name should be descriptive and indicative of the data it will store.
2. Columns (Fields): Tables consist of one or more columns, also known as fields. Each
column defines the type of data it can hold (e.g., text, numbers, dates) and can have
various constraints such as NOT NULL, unique, or primary key constraints.
3. Data Types: SQL Server provides a wide range of data types to define the kind of
data that can be stored in each column, such as INT, VARCHAR, DATETIME, etc.
4. Constraints: Constraints are rules that you can apply to columns to maintain data
integrity. Common constraints include PRIMARY KEY, FOREIGN KEY, UNIQUE,
and CHECK constraints.
Figure 1 Simple table queries
Where
table_name: The name of the table you want to create.
column1, column2, etc.: The names of the columns in the table.
datatype: The data type for each column.
constraint: Optional constraints for each column.
Then put the value into the tables using insert and set command.
Task 1:
Table query:
Task 2:
Conclusion:
In this lab, I learned about table creation, and all the constraints that can be applied in it.
Rubrics:
Report not Plagiarized Requirements Observations Appropriate Correctly
submitted content are listed and are recorded computation drawn
presented or experimental along with s or conclusion
Laboratory incomplete procedure is detailed numerical with
Reports submission or presented procedure analysis is exact results
late performed and complete
report in all
respects
Category Ungraded Very Poor Poor Fair Good Excellent
Marks 0 1 2 3 4 5
Marks 0 1 2 3 4 5