TL;DR – To insert new records in a table, the INSERT INTO statement is used. You can insert a whole new row and or just the selected data.
Contents
Inserting values into specified column names
Example
INSERT INTO mytable_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
Adding values for all the table columns
Example
INSERT INTO mytable_name
VALUES (value1, value2, value3, ...);
Example using a demo database
Pros Main Features
- Easy to use with a learn-by-doing approach
- Offers quality content
- Gamified in-browser coding experience
- The price matches the quality
- Suitable for learners ranging from beginner to advanced
- Free certificates of completion
- Focused on data science skills
- Flexible learning timetable
Pros Main Features
- Simplistic design (no unnecessary information)
- High-quality courses (even the free ones)
- Variety of features
- Nanodegree programs
- Suitable for enterprises
- Paid Certificates of completion
Pros Main Features
- A wide range of learning programs
- University-level courses
- Easy to navigate
- Verified certificates
- Free learning track available
- University-level courses
- Suitable for enterprises
- Verified certificates of completion
The Developers table
ID | Name | City | Country |
---|---|---|---|
1 | Tom Kurkutis | New York | USA |
2 | Ana Fernandez | London | UK |
3 | Antonio Indigo | Paris | France |
4 | Aarav Kaelin | Delhi | India |
5 | Andrew Tumota | Miami | USA |
Inserting a new row
Example
INSERT INTO Developers (Name, City, Country)
VALUES ('Luke Christon', 'London', 'UK');
The result
ID | Name | City | Country |
---|---|---|---|
1 | Tom Kurkutis | New York | USA |
2 | Ana Fernandez | London | UK |
3 | Antonio Indigo | Paris | France |
4 | Aarav Kaelin | Delhi | India |
5 | Andrew Tumota | Miami | USA |
6 | Luke Christon | London | UK |
Note: the ID column is automatically updated with a unique number for each table record.
Inserting a row with data in two columns
Example
INSERT INTO Customers (Name, City)
VALUES ('Winston Wellington', 'Oslo');
The result
ID | Name | City | Country |
---|---|---|---|
1 | Tom Kurkutis | New York | USA |
2 | Ana Fernandez | London | UK |
3 | Antonio Indigo | Paris | France |
4 | Aarav Kaelin | Delhi | India |
5 | Andrew Tumota | Miami | USA |
6 | Luke Christon | London | UK |
7 | Winston Wellington | Oslo | Null |