本系列為自己學習時的筆記及心得體會,轉載請注明出處。
1、插入完整的行
INSERT INTO Customers
VALUES
( '1000000006', 'Lottie Toys', '200 Maple Lane', 'Detroit', 'MI', '44444', 'USA', 'John Smith', 'sales@lottietoy.com' );
上述語句不安全,更安全的語句如下:
INSERT INTO Customers ( cust_id, cust_name, cust_address, cust_city, cust_state, cust_zip, cust_country, cust_contact, cust_email )
VALUES
( '1000000006', 'Lottie Toys', '200 Maple Lane', 'Detroit', 'MI', '44444', 'USA', 'John Smith', 'sales@lottietoy.com' );
2、插入部分行
INSERT INTO Customers ( cust_id, cust_name, cust_address, cust_zip, cust_country, cust_contact, cust_email )
VALUES
( '1000000006', 'Lottie Toys', '200 Maple Lane', 'USA', 'John Smith', 'sales@lottietoy.com' );
3、插入檢索出的數據
如下截圖的SQL,把CustNew表的數據復制到Customers表(注意:Custnew表的cust_id應與Customers表的cust_id不同)

上述CustNew和Customers表的列名可不一樣,因為它是按照列的位置去插入的。
4、創(chuàng)建表并把數據導入到新表
CREATE TABLE CustCopy AS
SELECT *
FROM Customers