Just a few weeks until the 2021 JavaScript Full-Stack Bootcamp opens.
Signup to the waiting list!
A database is composed by one or more tables.
Creating a table in SQL is done using the CREATE TABLE
command.
At creation time you need to specify the table columns names, and the type of data they are going to hold.
SQL defines several kinds of data.
The most important and the ones you’ll see more often are:
CHAR
TEXT
VARCHAR
DATE
TIME
DATETIME
TIMESTAMP
Numeric types include
TINYINT
1 byteINT
4 bytesBIGINT
8 bytesSMALLINT
2 bytesDECIMAL
FLOAT
They all hold numbers. What changes is the size that this number can be.
A TINYINT goes goes 0 to 255. An INT from -2^31 to +2^31.
The bigger the size in bytes, the more space will be needed in storage.
This is the syntax to create a people
table with 2 columns, one an integer and the other a variable length string:
CREATE TABLE people (
age INT,
name CHAR(20)
);
The 2021 JavaScript Full-Stack Bootcamp will start at the end of March 2021. Don't miss this opportunity, signup to the waiting list!
More database tutorials:
- The MongoDB basics tutorial
- How MongoDB is different from a SQL database
- Information systems, data and information
- Data models
- Introduction to the ER Data Model
- The Relational Model
- Relational Algebra
- Relational Databases
- What is a Database? And a DBMS?
- Introduction to SQL
- How to install PostgreSQL on macOS
- Do you always need a database for your app?
- How to install SQLite on macOS
- Introduction to PostgreSQL
- PostgreSQL User Permissions
- How to list all users in PostgreSQL
- How to switch database using PostgreSQL
- How to list all databases using PostgreSQL
- How to list tables in the current database using PostgreSQL
- How to install MySQL on macOS
- Creating a user on MySQL
- PostgreSQL vs MySQL, a comparison
- SQLite User Permissions
- MySQL User Permissions
- SQL, creating a table
- SQL, adding data to a table
- SQL, how to use SELECT
- SQL, Handling empty cells
- SQL, Unique and Primary keys
- SQL, how to update data
- SQL, how to update a table structure
- SQL, how to delete data and tables
- SQL Joins
- SQL Views
- How to insert multiple items at once in a MongoDB collection
- How to remove all items from a MongoDB collection