Creating a table
In this exercise, you will create a new table Person
. For this task, you have to
- define the table by using
CREATE TABLE
- define the necessary fields of the desired table
An example for creating a table Employee
is shown below:
CREATE TABLE Employee (
ID INT,
Name CHAR(32)
);
Your task is to create a new table, Person
, with the fields IndividualID
,Firstname
,Lastname
, Address
, and City
.
This exercise is part of the course
Hierarchical and Recursive Queries in SQL Server
Exercise instructions
- Define the table
Person
. - Define a field
IndividualID
. - Set
Firstname
andLastname
not to beNULL
and of typeVARCHAR(255)
. - Define
Birthday
asDATE
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
-- Define the table Person
CREATE TABLE ___ (
-- Define the Individual ID
___ INT NOT NULL,
-- Set Firstname and Lastname not to be NULL of type VARCHAR(255)
Firstname VARCHAR(___) NOT NULL,
Lastname ___(___) ___ ___,
Address VARCHAR(255) NOT NULL,
City CHAR(32) NOT NULL,
-- Define Birthday as DATE
Birthday ___
);
SELECT *
FROM Person;