Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Inserting Rows into a Table | Populating a Database
Introduction to SQL

bookInserting Rows into a Table

メニューを表示するにはスワイプしてください

After creating a table, we can insert rows into it using an INSERT statement.

Following is the general syntax of an INSERT statement:

INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);

In the above syntax, the table_name refers to the name of the table in which we want to insert a row.

The sequence of values (value1, value2, value3, ...) needs to be in the same order as the sequence of the columns that are specified at (column1, column2, column3, ...).

For example:

INSERT INTO students (first_name, second_name, age) VALUES ('John', 'Doe', 24);

// OR

INSERT INTO students (second_name, first_name, age) VALUES ('Doe', 'John', 24);

// OR

INSERT INTO students (age, first_name, second_name) VALUES (24, 'John', 'Doe');

// etc

Demonstration:

Tip:

There is a shorter syntax for inserting rows into a table:

INSERT INTO table_name VALUES (value1, value2, value3 …)

For example:

INSERT INTO students VALUES ('John', 'Doe', 24);

In this case, the order in which the values are stated should be the same as the default order of the columns.

The difference between the use cases of the two syntaxes we explored will become more apparent in the later chapters.

すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 4.  3

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

セクション 4.  3
some-alt