Archives November 2022

SQL statement types – Identify considerations for relational data on Azure

SQL statement types

SQL statements can be broadly classified into several types:

■■ Data Definition Language (DDL)

■■ Data Manipulation Language (DML)

■■ Data Control Language (DCL)

■■ Transaction Control Language (TCL)

Skill 2.1: Describe relational concepts     CHAPTER 2      35

DATA DEFINITION LANGUAGE

You’ll use DDL statements to create, modify, or delete the structure of database objects. The common statements are CREATE, ALTER, and DROP, as shown in Table 2-7.

TABLE 2-7  DDL statements

Figure 2-2 shows an example of the DDL CREATE statement that has been used to create a new table named Student with two columns: StudentID with the data type INT (an integer, or whole number) and FirstName with the data type VARCHAR (VARCHAR stands for variable-length character data).

FIGURE 2-2  DDL CREATE statement

Figure 2-3 shows an ALTER statement that has been used to alter the Students table by add-ing a new column named Email with a data type of VARCHAR (255).

FIGURE 2-3  DDL ALTER statement

Figure 2-4 shows the DROP statement used to delete the Student table from the database.

FIGURE 2-4  DDL DROP statement

36 CHAPTER 2     Identify considerations for relational data on Azure

Figure 2-5 shows the TRUNCATE statement used to delete all the records from the Students table while keeping the table structure for future use.

FIGURE 2-5 DDL TRUNCATE statement

Figure 2-6 shows the RENAME statement used to rename the Statement table to Learners.

FIGURE 2-6 DDL RENAME statement These DDL statements form the basis of structuring your data in a relational database. You’ll frequently use these commands as you build and manage your databases, so be sure to get comfortable with their syntax and uses. Practice is key!