LAB7
T_SQL Lab
Lab 7資料的新增、修改、刪除
1. Run the statement in the lab7_1.sql script to build the MY_EMPLOYEE table to be used for the lab.
執行 lab7_1.sql 檔案建立 MY_EMPLOYEE 資料表
CREATE TABLE MY_EMPLOYEE
(ID INT CONSTRAINT MY_EMPLOYEE_ID_NN NOT NULL,
LAST_NAME VARCHAR(25),
FIRST_NAME VARCHAR(25),
USERID VARCHAR(8),
SALARY decimal(9,2)
);
2. Add the first row of data to the MY_EMPLOYEE table from the following sample data. Do not list the columns in the INSERT clause.
新增INSERT一筆資料到MY_EMPLOYEE 資料表, 如員工編號ID 3,姓名last_name: Dancs ;不要列出欄位名稱
INSERT INTO my_employee
VALUES(3, 'Patel', 'Ralph', 'rpatel', 895)
3. Confirm your addition to the table
確認資料己新增到 表格中(即 查詢 資料表)
SELECT *
FROM my_employee
4. Change the last name of employee 3 to Drexler.
修改UPDATE員工編號(employee_id) 3 的員工姓名last_name為 Drexler
UPDATE my_employee
SET last_name = 'Drexler'
WHERE id = 3
5. Delete Drexler from the MY_EMPLOYEE table.
刪除 員工姓名last_name為 Drexler之員工資料
DELETE FROM my_employee
WHERE last_name = 'Drexler'
6. Empty the entire table.
刪除 MY_EMPLOYEE表格中所有的資料列
DELETE FROM my_employee
Lab 8補充 進階SQL指令 介紹
參考 講義範例