The SQL INSERT INTO statement is used to insert new records into a table. The syntax of the INSERT INTO statement is as follows:
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
Here, table_name is the name of the table into which you want to insert data. column1, column2, column3, etc. are the names of the columns in the table. If you want to insert data into specific columns, you need to specify those columns after the table_name. The VALUES keyword is followed by the values that you want to insert into the columns. The number of values should match the number of columns specified.
Examples:
INSERT INTO customers (first_name, last_name, email, age)
VALUES ('John', 'Doe', 'johndoe@example.com', 30);
INSERT INTO customers (first_name, last_name, email, age) VALUES (‘John’, ‘Doe’, ‘johndoe@example.com’, 30);
In this example, a new record is inserted into the customers table with the values ‘John’ for first_name, ‘Doe’ for last_name, ‘johndoe@example.com‘ for email, and 30 for age.
INSERT INTO orders (customer_id, order_date, total_amount)
VALUES (101, '2022-03-25', 125.50);
In this example, a new record is inserted into the orders table with the values 101 for customer_id, ‘2022-03-25’ for order_date, and 125.50 for total_amount.
By using the INSERT INTO statement, you can insert new records into a table and add data to your database.
Learners TV is a website that is designed to educate users and provide instructional material on particular subjects and topics.