STRUCTURED QUERY LANGUAGE
HOW TO CREATE TABLES USING SQL?
SQL (Structured Query Language) is a powerful language
used to manage and manipulate relational databases. In this
chapter, we will learn how to create tables in SQL.
Setting up the database
Let's start by setting up a new database in MySQL, which we
will use for this chapter. To do this, we can use the following
commands in the MySQL command-line tool:
CREATE DATABASE company;
USE company;
This creates a new database named "company" and switches
to it.
Creating a table
Now that we have our database set up, we can create a
table. Let's create a table to store employee information.
We can use the CREATE TABLE statement to create a new
table. The basic syntax is as follows:
CREATE TABLE table_name (
column1_name data_type(length) constraint,
column2_name data_type(length) constraint,
...
HOW TO CREATE TABLES USING SQL?
SQL (Structured Query Language) is a powerful language
used to manage and manipulate relational databases. In this
chapter, we will learn how to create tables in SQL.
Setting up the database
Let's start by setting up a new database in MySQL, which we
will use for this chapter. To do this, we can use the following
commands in the MySQL command-line tool:
CREATE DATABASE company;
USE company;
This creates a new database named "company" and switches
to it.
Creating a table
Now that we have our database set up, we can create a
table. Let's create a table to store employee information.
We can use the CREATE TABLE statement to create a new
table. The basic syntax is as follows:
CREATE TABLE table_name (
column1_name data_type(length) constraint,
column2_name data_type(length) constraint,
...