SELECT * FROM EMP;
INSERT INTO EMP VALUES (7777,'์ด์ฉํ','DEVELOPER','7777',SYSDATE,4000,500,20);
SELECT * FROM EMP;
INSERT INTO EMP ( EMPNO, ENAME, DEPTNO ) VALUES (7778,'ํ๊ธธ๋',10);
SELECT * FROM EMP;
INSERT INTO EMP (EMPNO, ENAME, DEPTNO ) VALUES(7777,'์ฑ์ถํฅ',10);--PK์ค๋ณต
INSERT INTO EMP (EMPNO, ENAME, DEPTNO ) VALUES(7779,'๋ฌด์ง๊ฐ',50);
SELECT * FROM DEPT;
-- UPDATE
SELECT * FROM PLAYER; --PLAYERํ
์ด๋ธ ํ์ธ
-- PLAYER ํ
์ด๋ธ์์ TEAM_ID๊ฐ K01์ธ ์ ์ ์ด๋ฆ์ ๋ณธ์ธ ์ด๋ฆ์ผ๋ก ๋ฐ๊ฟ๋ณด์
-- ๋ณ๊ฒฝ ์
SELECT * FROM PLAYER WHERE TEAM_ID = 'K01'; --TEAM_ID๊ฐ 'K01'์ธ ์ ์ํ์ธ.
-- ๋ณ๊ฒฝ
UPDATE PLAYER SET PLAYER_NAME = '๊น์ฒ ์'
WHERE TEAM_ID = 'K01'; --PLAYER ํ
์ด๋ธ์์ TEAM_ID๊ฐ 'K01'์ธ ์ฌ๋์ PLAYER_NAME์ '๊น์ฒ ์'๋ก ๋ฐ๊ฟ.
-- ๋ณ๊ฒฝ ํ
SELECT * FROM PLAYER WHERE TEAM_ID = 'K01'; --TEAM_ID๊ฐ 'K01'์ธ PLAYER ํ์ธ.
SELECT * FROM PLAYER; --PLAYER ํ
์ด๋ธ ํ์ธ.
SELECT NICKNAME FROM PLAYER; --PLAYERํ
์ด๋ธ์์ NICKNAME๋ง ํ์ธ.
-- NULL ๋น๊ต๋ ์ผ๋ฐ ์ฐ์ฐ์ ๋น๊ต๋ ๋ค๋ฅด๋ค. IS NULL // IS NOT NULL
UPDATE PLAYER SET NICKNAME = 'DBMS' WHERE NICKNAME = NULL;
UPDATE PLAYER SET NICKNAME = 'DBMS' WHERE NICKNAME IS NULL;
-- PLAYER ํ
์ด๋ธ์์ POSITION์ด DF์ด๊ณ TEAM_ID๊ฐ K04์ธ ์ ์ ๊ตญ์ ( NATION )์ ํ๊ตญ์ผ๋ก ๋ฐ๊พธ๊ธฐ.
UPDATE PLAYER SET NATION = 'ํ๊ตญ' WHERE POSITION ='DF' AND TEAM_ID = 'K04'; --
SELECT NATION FROM PLAYER; --PLAYER ํ
์ด๋ธ์ NATION ์ปฌ๋ผ์ ํ์ธ.
-- DELETE
SELECT * FROM EMP;
DELETE FROM EMP WHERE EMPNO = 7777;
-- SYSDATE, DATE
SELECT SYSDATE FROM DUAL; --DUALํ
์ด๋ธ์์ SYSDATE ํ์ธ.
-- SYSDATE : ํ์ฌ ์๊ฐ์ ๋ํ๋
-- DUAL ํ
์ด๋ธ : ํจ์, ๊ณ์ฐ ๊ฐ์ ์ฐ์ต์ฉ ํ
์ด๋ธ ( ์ค๋ผํด์์ ์ ๊ณต )
SELECT 1+2 AS ๊ฒฐ๊ณผ FROM DUAL; --์ฐ์ต์ฉํ
์ด๋ธ์์ 1+2์ ๊ฐ์ '๊ฒฐ๊ณผ'๋ผ๋ ์ปฌ๋ผ์ ์ถ๋ ฅ.
SELECT 1+2 FROM DUAL;
SELECT * FROM DUAL;
-- Alias ๋ณ์นญ => AS ์ฌ์ฉ.
SELECT ENAME AS ์ด๋ฆ FROM EMP; --EMP ํ
์ด๋ธ์์ ENAME์ปฌ๋ผ์ ๊ฐ๋ค์ ํ์ธํ๊ณ ์ปฌ๋ผ๋ช
์ '์ด๋ฆ'์ผ๋ฌ ์ถ๋ ฅ.
SELECT * FROM EMP; -- EMPํ
์ด๋ธ์ ํ์ธํด๋ ENAME์ด๋ผ๋ ์ปฌ๋ผ๋ช
์ด ๋ณํ์ง๋ ์์.
':: DBMS ๐ฉ > OracleDB' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[DBMS] SQL -7- [SELECT, COMMIT] (0) | 2021.03.22 |
---|---|
[DBMS] SQL -6- [SELECT] (0) | 2021.03.22 |
[DBMS] SQL ๊ฐ๋ -2- "E-R๋ชจ๋ธ, ์ ๊ทํ, ์ํ์ค ( Sequence )" (0) | 2021.03.22 |
[DBMS] - 4 - SQL - DROP, TRUNCATE (0) | 2021.03.16 |
[DBMS] -3- SQL - ALTER (0) | 2021.03.15 |
๋๊ธ