Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Creating a Table | Populating a Database
Introduction to SQL
course content

Conteúdo do Curso

Introduction to SQL

Introduction to SQL

1. Getting Started
3. Sorting Data
4. Populating a Database
5. Updating & Deleting Data

book
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:

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 4. Capítulo 1
We're sorry to hear that something went wrong. What happened?
some-alt