Conteúdo do Curso
Introduction to SQL
Introduction to SQL
Creating a Table
For storing data into an SQL-based DBMS, we first create and select a database instance. We can do so by using the following query:
Where db_name
refers to the name of the database which we want to create.
Note
There can be more than one database instance in a DBMS, each containing their own set of tables.
Once the database is created, we can create a table using the following syntax:
The table_name
indicates the name of the table which is to be created. Inside the brackets (...)
, we write the column names that are to be included in the table, followed by their respective data types. Each column-datatype pair is separated by commas (,
).
Following is a simple CREATE TABLE
query, which creates a table called students
with three columns, namely: first_name
, last_name
, age
:
Following are the common datatypes in SQL:
Demonstration:
Good Practice:
Obrigado pelo seu feedback!