SQLBolt:https://sqlbolt.com/lesson/introduction
INSERT
INSERT rows 插入 / 新增行 -- 也就是 儲存record
,這我們在 Day 10 就已經做過了。這次我們使用 SQLBolt 的語法說明來解釋。
/* Insert statement with values for all columns */
INSERT INTO mytable
VALUES (value_or_expr, another_value_or_expr, …),
(value_or_expr_2, another_value_or_expr_2, …),
…;
/* Insert statement with specific columns */
INSERT INTO mytable
(column, another_column, …)
VALUES (value_or_expr, another_value_or_expr, …),
(value_or_expr_2, another_value_or_expr_2, …),
…;
/* Example Insert statement with expressions */
INSERT INTO boxoffice
(movie_id, rating, sales_in_millions)
VALUES (1, 9.9, 283742034 / 1000000);
-- 1. Add the studio's new production, Toy Story 4 to the list of movies (you can use any director)
INSERT INTO movies
VALUES (4, "Toy Story 4", "El Directore", 2015, 90);
-- 2. Toy Story 4 has been released to critical acclaim! It had a rating of 8.7, and made 340 million domestically and 270 million internationally. Add the record to the BoxOffice table.
INSERT INTO boxoffice
VALUES (4, 8.7, 340000000, 270000000);
今天介紹了如何儲存資料(record),明天的主題則是如何修改 & 刪除這些資料的值。
參考資料: