SQL 入门教程:数据插入(INSERT)练习题

本文内容

  1. 使用 INSERT 和指定的列,将你自己添加到 Customers 表中。明确列出要添加哪几列,且仅需列出你需要的列。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    
    -- 显然要用你自己的内容替换。
    INSERT INTO Customers(cust_id, 
    cust_name, 
    cust_address, 
    cust_city, 
    cust_state, 
    cust_zip, 
    cust_country, 
    cust_email) 
    VALUES(1000000042, 
    'Ben''s Toys', 
    '123 Main Street', 
    'Oak Park', 
    'MI', 
    '48237', 
    'USA', 
    '[email protected]');
    
  2. 备份 Orders 表和 OrderItems 表。

    1
    2
    3
    4
    5
    6
    
    -- MySQL, MariaDB, Oracle, PostgreSQL, SQLite 
    CREATE TABLE OrdersBackup AS SELECT * FROM Orders; 
    CREATE TABLE OrderItemsBackup AS SELECT * FROM OrderItems; 
    -- SQL Server 
    SELECT * INTO OrdersBackup FROM Orders; 
    SELECT * INTO OrderItemsBackup FROM OrderItems;
    

请参阅

(完)

comments powered by Disqus

本文内容