From 0c02e0b8c345aea8c32673f61fc412c31dce93d8 Mon Sep 17 00:00:00 2001 From: syneffort Date: Wed, 21 Sep 2022 14:03:05 +0900 Subject: [PATCH] update delete --- delete using subquery.sql | 9 +++++++++ delete.sql | 16 ++++++++++++++++ insert multi tuples.sql | 13 +++++++++++++ insert test table.sql | 13 +++++++++++++ insert using subquery.sql | 5 +++++ insert.sql | 11 +++++++++++ select into.sql | 6 ++++++ table structure copy (select into).sql | 7 +++++++ table structure select.sql | 6 ++++++ update by subquery.sql | 10 ++++++++++ update multi properties.sql | 10 ++++++++++ update.sql | 15 +++++++++++++++ 12 files changed, 121 insertions(+) create mode 100644 delete using subquery.sql create mode 100644 delete.sql create mode 100644 insert multi tuples.sql create mode 100644 insert test table.sql create mode 100644 insert using subquery.sql create mode 100644 insert.sql create mode 100644 select into.sql create mode 100644 table structure copy (select into).sql create mode 100644 table structure select.sql create mode 100644 update by subquery.sql create mode 100644 update multi properties.sql create mode 100644 update.sql diff --git a/delete using subquery.sql b/delete using subquery.sql new file mode 100644 index 0000000..190b0d4 --- /dev/null +++ b/delete using subquery.sql @@ -0,0 +1,9 @@ +USE Study +GO + +SELECT * FROM EMPTEST + +DELETE EMPTEST +WHERE DNO = (SELECT DNO FROM DEPARTMENT WHERE DNAME = 'Accounting') + +SELECT * FROM EMPTEST \ No newline at end of file diff --git a/delete.sql b/delete.sql new file mode 100644 index 0000000..447eace --- /dev/null +++ b/delete.sql @@ -0,0 +1,16 @@ +USE Study +GO + +SELECT * FROM DEPTEST + +DELETE DEPTEST -- ¸ðµç Æ©Çà »èÁ¦ + +SELECT * FROM DEPTEST + +SELECT * FROM EMPTEST + +DELETE EMPTEST +WHERE SALARY < 400; + +SELECT * FROM EMPTEST + diff --git a/insert multi tuples.sql b/insert multi tuples.sql new file mode 100644 index 0000000..a202c69 --- /dev/null +++ b/insert multi tuples.sql @@ -0,0 +1,13 @@ +USE Study +GO + +CREATE TABLE DEPT01( + DNO INT, + DNAME VARCHAR(20), + ADDRESS VARCHAR(20), +) + +INSERT INTO DEPT01 +VALUES + (200, 'dept001', 'seoul'), + (201, 'dept002', 'incheon') \ No newline at end of file diff --git a/insert test table.sql b/insert test table.sql new file mode 100644 index 0000000..7f7c65a --- /dev/null +++ b/insert test table.sql @@ -0,0 +1,13 @@ +USE STUDY +GO + +CREATE TABLE EMPTEST( + ENO INT, + ENAME NVARCHAR(20), + JOB NVARCHAR(20), + MANAGER INT, + HIREDATE DATETIME, + SALARY INT, + COMMISSION INT, + DNO INT +) \ No newline at end of file diff --git a/insert using subquery.sql b/insert using subquery.sql new file mode 100644 index 0000000..fb50077 --- /dev/null +++ b/insert using subquery.sql @@ -0,0 +1,5 @@ +USE Study +GO + +INSERT INTO EMPTEST + SELECT * FROM EMPLOYEE WHERE DNO = 30 \ No newline at end of file diff --git a/insert.sql b/insert.sql new file mode 100644 index 0000000..30ca5b3 --- /dev/null +++ b/insert.sql @@ -0,0 +1,11 @@ +USE Study +GO + +INSERT INTO EMPTEST +VALUES (50, 'È«±æµ¿', 'staff', NULL, '2022-01-01', 500, 30, 10) + +INSERT INTO EMPTEST (ENO, ENAME) +VALUES (51, '½ÉûÀÌ') + +INSERT INTO EMPTEST +VALUES (52, 'ÀÓ²©Á¤', NULL, NULL, NULL, NULL, NULL, NULL) \ No newline at end of file diff --git a/select into.sql b/select into.sql new file mode 100644 index 0000000..1952495 --- /dev/null +++ b/select into.sql @@ -0,0 +1,6 @@ +USE Study +GO + +SELECT DNO, DNAME INTO DEPTEST +FROM DEPARTMENT +WHERE DNO = 30 \ No newline at end of file diff --git a/table structure copy (select into).sql b/table structure copy (select into).sql new file mode 100644 index 0000000..ec3a77b --- /dev/null +++ b/table structure copy (select into).sql @@ -0,0 +1,7 @@ +USE Study +GO + +-- Å×ÀÌºí ±¸Á¶¸¸ º¹»ç +SELECT * INTO DEPT_COPY +FROM DEPARTMENT +WHERE 1 > 2 -- Ç×»ó °ÅÁþÀÌ µÇ´Â Á¶°Ç \ No newline at end of file diff --git a/table structure select.sql b/table structure select.sql new file mode 100644 index 0000000..e932b87 --- /dev/null +++ b/table structure select.sql @@ -0,0 +1,6 @@ +USE Study +GO + +SELECT * FROM DEPTEST + +EXEC sp_help DEPTEST \ No newline at end of file diff --git a/update by subquery.sql b/update by subquery.sql new file mode 100644 index 0000000..827d262 --- /dev/null +++ b/update by subquery.sql @@ -0,0 +1,10 @@ +USE Study +GO + +SELECT * FROM EMPTEST + +UPDATE EMPTEST +SET MANAGER = (SELECT MANAGER FROM EMPLOYEE WHERE ENO = 101) +WHERE ENO = 50 + +SELECT * FROM EMPTEST \ No newline at end of file diff --git a/update multi properties.sql b/update multi properties.sql new file mode 100644 index 0000000..b2472a8 --- /dev/null +++ b/update multi properties.sql @@ -0,0 +1,10 @@ +USE Study +GO + +SELECT * FROM EMPTEST + +UPDATE EMPTEST +SET SALARY = 300, COMMISSION = 50 +WHERE ENO = 51 + +SELECT * FROM EMPTEST diff --git a/update.sql b/update.sql new file mode 100644 index 0000000..d459dcc --- /dev/null +++ b/update.sql @@ -0,0 +1,15 @@ +USE Study +GO + +SELECT * FROM EMPTEST + +UPDATE EMPTEST +SET SALARY = SALARY * 1.1 + +SELECT * FROM EMPTEST + +UPDATE EMPTEST +SET JOB = 'staff' +WHERE DNO = 30 + +SELECT * FROM EMPTEST