Table (SQL)

A table is the basic structure that holds data in a relational database. It is organized like a spreadsheet, with rows for individual records and columns for each piece of information.

SQL

Every table has a name and a set of columns, each with a defined data type such as INT or TEXT. Each row in the table represents one entry — for example, one customer or one order.

You create a table with CREATE TABLE and define its columns and rules up front. Tables are where all of your data ultimately lives.

Syntax

CREATE TABLE table_name (
  column1 datatype,
  column2 datatype
);

Examples

SQL

CREATE TABLE users (
  id INT PRIMARY KEY,
  name TEXT,
  age INT
);

Output:

Table 'users' created.

Learn it in a lesson

See also

Back to the Dictionary