$ brew install colima
$ brew install --cask docker
$ colima start --memory 4 --arch x86_64
$ docker ps // 실행 중
$ docker ps -a // 종료된 것
$ docker start 컨테이너명
$ docker restart 컨테이너명
$ docker run -e ORACLE_PASSWORD=pass -p 1521:1521 -d gvenzl/oracle-xe
$ docker ps
$ docker rename 현재컨테이너이름 변경할이름
$ docker exec -it oracle sqlplus
system
pass
ace
ace
system as sysdba
oracle
docker stop 컨테이너명
colima stop
sqlplus 뒤에 붙이고 사용
docker exec -it oracle sqlplus ace/ace@localhost:1521/xepdb1
conn ace/ace@localhost:1521/xepdb1
docker exec -it oracle bash
쉘에서
sqlplus /nolog
conn ace/ace@localhost:1521/xepdb1
docker exec
docker rm 컨테이너이름
docker exec -it oracle sqlplus
docker exec -it oracle sqlplus /nolog
conn sys/pass@localhost:1521/xepdb1 as sysdba
docker exec -i oracle sqlplus sys as sysdba/pass@localhost:1521/xepdb1
docker exec -i oracle sqlplus system/pass@localhost:1521/xepdb1
docker exec -i oracle sqlplus ace/ace@localhost:1521/xepdb1
=============================
Oracle 21c XE 설치 후
=============================
C:\Users\COM> notepad xe_start.bat
net start OracleOraDB21Home1TNSListener
net start OracleServiceXE
C:\Users\COM> notepad xe_stop.bat
net stop OracleServiceXE
net stop OracleOraDB21Home1TNSListener
C:\Users\COM> xe_stop
C:\Users\COM> xe_start
# Connecting to a Pluggable Database (PDB)
참고.https://oracle-base.com/articles/12c/multitenant-connecting-to-cdb-and-pdb-12cr1#pdb
[1] 설치 뒤 SQL*Plus로 접속
C:\Users\COM> sqlplus / as sysdba <- CDB에 접속하는 것임
SQL> col name format a30
SQL> col pdb format a30
SQL> select name, pdb
from v$services
order by name;
NAME PDB
------------------------------ ------------------------------
SYS$BACKGROUND CDB$ROOT
SYS$USERS CDB$ROOT
xe CDB$ROOT <- CDB(Container Database)
xeXDB CDB$ROOT
xepdb1 XEPDB1 <- PDB(Pluggable Database), 우리가 사용할 DB
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> alter session set container = xepdb1;
SQL> show con_name
SQL> exit
C:\Users\COM> sqlplus system/oracle@localhost:1521/xepdb1 <- PDB에 관리자로 접속
C:\Users\COM> sqlplus pass/oracle@localhost:1521/xepdb1 <- PDB에 관리자로 접속
SQL> show con_name
CON_NAME
------------------------------
XEPDB1
SQL> select * from session_privs;
SQL > drop user ace cascade;
SQL> create user ace identified by ace default tablespace users temporary tablespace temp;
SQL> alter user ace quota unlimited on users;
SQL> grant connect, resource, create session, create table, create procedure, create trigger, create view, create sequence to ace;
SQL> exit
C:\Users\COM> sqlplus ace/ace@localhost:1521/xepdb1
C:\Users\COM> conn ace/ace@localhost:1521/xepdb1
SQL> show con_name
CON_NAME
------------------------------
XEPDB1
SQL> show user
USER은 "ACE"입니다
docker exec -i 컨테이너이름 sqlplus ace/ace@localhost:1521/xepdb1 < 경로
172.17.0.2
https://brunch.co.kr/@hopeless/10
https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/index.html#Oracle%C2%AE-Database
select * from tab;
select last_name, to_char(dhire_date, 'YYYY/MM/DD') as hire_date
from employees;
select * from employees;
-- employees 에서 이름(last_name), 급여(salary), 연봉(salary*12+salary*commission_pct) 출력
SELECT last_name as 이름, salary as 급여, (salary * 12 + salary * nvl(commission_pct,0)) as 연봉 from employees;
create user tester1
identified by 1234
account unlock;
alter user tester1
identified by 1234;
alter user tester1
default tablespace users
temporary tablespace temp
quota unlimited on users;
select username from dba_users
where username like '%TESTER%';
grant connect,
resource,
create session,
create table,
create procedure,
create trigger,
create view,
create sequence
to tester1;
select rowid, deptno, dname, loc
from dept;
-- 부서 테이블 제거하기
DROP TABLE EMP;
-- 사원 테이블 제거하기
DROP TABLE DEPT;
-- 급여 테이블 제거하기
DROP TABLE SALGRADE;
-- 부서 테이블 제거하기
DROP TABLE EMPLOYEE;
-- 사원 테이블 제거하기
DROP TABLE DEPARTMENT;
-- 급여 테이블 제거하기
DROP TABLE SALGRADE;
-- 부서 테이블 생성하기
CREATE TABLE DEPT(
DEPTNO NUMBER(2) CONSTRAINT PK_DEPT PRIMARY KEY,
DNAME VARCHAR2(14),
LOC VARCHAR2(13) ) ;
-- 사원 테이블 생성하기
CREATE TABLE EMP(
EMPNO NUMBER(4) CONSTRAINT PK_EMP PRIMARY KEY,
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(7,2),
COMM NUMBER(7,2),
DEPTNO NUMBER(2) CONSTRAINT FK_DEPTNO REFERENCES DEPT);
-- 급여 테이블 생성하기
CREATE TABLE SALGRADE(
GRADE NUMBER,
LOSAL NUMBER,
HISAL NUMBER );
-- 사원 테이블에 샘플 데이터 추가하기
INSERT INTO DEPT VALUES(10, '경리부', '서울');
INSERT INTO DEPT VALUES(20, '인사부', '인천');
INSERT INTO DEPT VALUES(30, '영업부', '용인');
INSERT INTO DEPT VALUES(40, '전산부', '수원');
-- 부서 테이블에 샘플 데이터 추가하기
INSERT INTO EMP VALUES(1001, '김사랑', '사원', 1013, to_date('2007-03-01','yyyy-mm-dd'), 300, NULL, 20);
INSERT INTO EMP VALUES(1002, '한예슬', '대리', 1005, to_date('2007-04-02','yyyy-mm-dd'), 250, 80, 30);
INSERT INTO EMP VALUES(1003, '오지호', '과장', 1005, to_date('2005-02-10','yyyy-mm-dd'), 500, 100, 30);
INSERT INTO EMP VALUES(1004, '이병헌', '부장', 1008, to_date('2003-09-02','yyyy-mm-dd'), 600, NULL, 20);
INSERT INTO EMP VALUES(1005, '신동협', '과장', 1005, to_date('2005-04-07','yyyy-mm-dd'), 450, 200, 30);
INSERT INTO EMP VALUES(1006, '장동건', '부장', 1008, to_date('2003-10-09','yyyy-mm-dd'), 480, NULL, 30);
INSERT INTO EMP VALUES(1007, '이문세', '부장', 1008, to_date('2004-01-08','yyyy-mm-dd'), 520, NULL, 10);
INSERT INTO EMP VALUES(1008, '감우성', '차장', 1003, to_date('2004-03-08','yyyy-mm-dd'), 500, 0, 30);
INSERT INTO EMP VALUES(1009, '안성기', '사장', NULL, to_date('1996-10-04','yyyy-mm-dd'),1000, NULL, 20);
INSERT INTO EMP VALUES(1010, '이병헌', '과장', 1003, to_date('2005-04-07','yyyy-mm-dd'), 500, NULL, 10);
INSERT INTO EMP VALUES(1011, '조향기', '사원', 1007, to_date('2007-03-01','yyyy-mm-dd'), 280, NULL, 30);
INSERT INTO EMP VALUES(1012, '강혜정', '사원', 1006, to_date('2007-08-09','yyyy-mm-dd'), 300, NULL, 20);
INSERT INTO EMP VALUES(1013, '박중훈', '부장', 1003, to_date('2002-10-09','yyyy-mm-dd'), 560, NULL, 20);
INSERT INTO EMP VALUES(1014, '조인성', '사원', 1006, to_date('2007-11-09','yyyy-mm-dd'), 250, NULL, 10);
-- 급여 테이블에 샘플 데이터 추가하기
INSERT INTO SALGRADE VALUES (1, 700,1200);
INSERT INTO SALGRADE VALUES (2, 1201,1400);
INSERT INTO SALGRADE VALUES (3, 1401,2000);
INSERT INTO SALGRADE VALUES (4, 2001,3000);
INSERT INTO SALGRADE VALUES (5, 3001,9999);
COMMIT;
OR | TRUE | FALSE | NULL |
---|---|---|---|
TRUE | TRUE | TRUE | TRUE |
FLASE | TRUE | FALSE | NULL |
NULL | TRUE | NULL | NULL |
AND | TRUE | FALSE | NULL |
---|---|---|---|
TRUE | TRUE | FALSE | NULL |
FLASE | FALSE | FALSE | NULL |
NULL | NULL | NULL | NULL |
SELECT ename, sal*12+NVL(comm, 0) as Annsal
FROM emp;
SELECT ename, sal*12+NVL(comm, 0) Annsal
FROM emp;
SELECT ename || '의 직급은 ' || job || '입니다.' as 직급
FROM emp;
SELECT deptno
FROM emp;
google lighthouse
jwt토큰으로 로그인 만료 관리
파일 업로드시 확장자 검증
개인정보 마스킹
추천 알고리즘 join 4번의 쿼리
SELECT *
FROM emp
WHERE hiredate < TO_DATE('2005/01/01', 'YYYY/MM/DD');
SELECT *
FROM emp
WHERE deptno=10 AND job='과장';
SELECT *
FROM emp
WHERE deptno=10 OR job='과장';
SELECT *
FROM emp
WHERE depto = 10;
select last_name, department_id
from employees
where department_id is not null;
select *
from emp
where 400 <= sal and sal <= 500;
select *
from emp
where sal between 400 and 500;
select *
from emp
where sal>=400 and sal<=500;
select *
from emp
where comm=80 or comm=100 or comm=200;
Select *
from emp
where hiredate between to_date('2003/01/01', 'YYYY/MM/DD')
and to_date('2003/12/31', 'YYYY/MM/DD');
select *
from emp
where to_char(hiredate,'YYYY') = 2003;
-> 해당 코드에서 아래코드를 사용할 경우 모든 날짜 정보를 YYYY형태로 바꿔버리기 때문에 비효율적이다.
-> 위 코드를 사용하는 것이 좋다.
SELECT *
FROM emp
WHERE comm=80 Or comm=100 OR comm=200;
SELECT *
FROM emp
WHERE comm NOT IN(80, 100, 200);