Data definition language
Data definition language is the part of the SQL language that you use to manage objects in a database. By manage, we mean the following:
CREATE
ALTER
DROP
You need to be able to create new objects, most notably, new tables. You also need to be able to alter existing tables or drop existing tables. The same holds for other objects, such as views and stored procedures. That is why we have three statements. Let's start with CREATE TABLE
.
Creating a table
You create a new table using the CREATE TABLE
statement:
- Click, in Azure Data Studio, on the New Query button to open a new query file (see Figure 4.8).
- Enter the following code (you can find the code in the
Create table Product.sql
file in the downloads):CREATE TABLE [dbo].[Product] ( ProductID INT IDENTITY (1,1) NOT NULL, ProductName NVARCHAR(40) NOT NULL, SupplierID INT NULL, CategoryID INT NULL, QuantityPerUnit NVARCHAR(20) NULL, UnitPrice MONEY NULL, UnitsInStock...