(오라클) 통합 문제

main --1. 임의의 테이블 스페이스 (samtb( 논리적이름 ),damtb.dbf( 물리적이름 ) 를 만들기 . = > 크기는 1GB     create tablespace samtb     datafile 'd:\dbspace\damtb.dbf'         size 1G;         --2. 생성된 테이블스페이스의 크기를 2GB 로 변경하기 .     ALTER DATABASE DATAFILE 'd:\dbspace\damtb.dbf'    RESIZE 2G; --3. 테이블 스페이스의 물리적 이름을 변경하기 .(damtb.dbf 를 samtb.dbf) --4. 임의의 사용자를 생성하고 생성된 테이블스페이스를 지정하기 .     create user lucky identified by lucky     default tablespace samtb     ; --5. 생성된사용자에 대한 권한 (connect,resource) 을 부여하기 .     grant resource, connect to lucky;     --6. 생성된 사용자에 대한 퍼블릭 시노님 생성 권한 부여하기 .     grant create public synonym to lucky; --7.hr 권한에 대한 비밀번호 변경하기 . (hr=>hr1234)     alter user hr identified by   hr1234; -...

(오라클+자바) 데이타베이스에 데이타 올리기 - 05

이미지
모든걸 하기전에 우리는 준비를 해야한다. 자바를 시작하기 전에 1.먼저 드라이버를 java안에 설치한다. 드라이버란 ob 2.DB의 계정하고 비번을 알아야한다. 그렇게 하면 DB가 연결이 된다. 3.자료를 저장할 테이블을 만든다 자바에 들어가서 4. 데이타의 타입을 정한다 -> 그걸 우린 DTO를 만드는것이다. 5.필드명을 대문자로 한다 (규칙) 먼저 오라클에서 테이블을 만들어서 칼람명을 정해주어야한다. 이게 데이타 저장소의 뼈대이다. 먼저 이렇게 만들어보자 create table GUESTBOOK( MESSAGE_ID NUMBER(8) CONSTRAINT MES_ID_PK PRIMARY KEY (MESSAGE_ID), GUEST_NAME VARCHAR2(50) NOT NULL, GUEST_PWD VARCHAR2(10) NOT NULL, MESSAGE VARCHAR2(1024) NOT NULL, ); 그럼 저 comment는 무엇일까? COMMENT ON TABLE guestbook.message_id IS '메세지 번호' ; 이렇게 comment을 달아주면 된다. 그리고 우리는 eclipse에 가서 DTO를 만들어줘야하는데 DTO가 무엇이냐..? Data Transfer Object 이다. 근데 이걸 왜 만들어줘야하냐? 영어 되는 사람 여기 클릭 package com.guestbookDTO.www; public class GuestBookVO { private int messageId; private String  guestName; private String password; private String message; public GuestBookVO() { super(); } public int getMessageId() { ...

(오라클) 뷰 + 조인 예제

이미지
hr계정에서 자신이 소유한 정부중에서 사원번호, 이름 , 메일주소, 전화번호, 직책명, 부서명을 임의의 사용자(내 경우에선 imsihyun)에게 조회만 가능하도록 권환을 부여하시오 아물로 임의의 사용자 계정으로 접속후 결과를 확인하세요. 먼저 이걸 해석할수 있는 순서를 나눠보자 1. join 하기 2. join 한 view를 만들기 3. 권한 주기 더 디테일하게 선생님이 써주신 글들을 여기 아래다가 써놨다 요구사항을 분석 자료의 접근에 관련된 사항이기때문에->table,view라는 객체가 작업의 대상이 된다. 각각 테이블 또는 뷰에서 원하는 정보를 얻기위해 필요한 객체가 무엇 인지를 파악하자. 고려사항!!!!!!!!!!! 완전 중요!!! NULL에 대한 고찰이 필요하다!!!!!!!!!!!!!!!! null은 departmentname에 null이란 값이있다. 이게 고려사항이다. null 무시 -> inner join 하기 null x무시 -> outer join 하기 ansi표준의 쿼리를 통한 조인을 할것인지 결정하자 join에 대해서는 이미 써줬다.  hr 계정에 있는 우리가 불러와야하는 테이블들은... employees 테이블 안에있는것들 사원번호 -> employees_id 이름 -> first_name, last_name 메일주소 ->email 전화번호->phone_number departments 테이블 안에 있는것들 부서명 -> department_name jobs 테이블 안에 있는것들 job_title 이걸 먼저 다 조인해서 할것이다. SELECT employees.employee_id, employees.first_name, employees.last_name, employees.email, departments.department_name,jobs.job_title FROM employees, d...

(오라클) join

이미지
WE use DB for enterprise decision. select sum(salary) as total from employees;  select max(salary) from employees; max->최대 select count(employee_id) from employees; select count(commission_pct) from employees; select count(*), department_id from employees group by department_id; select- 고르다 count(*) - 모두다 센다 department_id를  어디서? employees 에서 department_id 부서별로. select avg(salary) ,department_id, count(*)  인원수 from employees group by department_id; avg(salary) -> 평균 월급 department_id -> 부서 아이디 를 출력하고, count(*) 인원수 -> 인원수를 다 세고 group by department_id-> 부서별로 나눈다 select round( avg(salary) ) ,department_id,count(*)인원수 from employees group by department_id; real number -> integer we use round() ' select * from departments where department_id = 90; join join type -> inner/outer/ inner join  inner  join, The method to join the same data in the two diff...

(오라클) view/뷰

이미지
"view" view isn't a physical table, it is virtual (default) table that doesn't actually store the data. DB developer should know how to use view in DB oracle, as the DB developer able to restrict the table that can be viewed by selected individuals/groups. We gonna enter to 'hr' account to create a view. The formula for view: create view view_name as select first_name, last_name, email, hire_date from employees; The detailed formula for the view create (or replace) [{force | no force }] view view_name as [with check option] [with read only];  1. create or replace actually, you can just use create only. but if you use replace with the create, you can create&edit the view at the same time. 2. force | no force you can force to create view even if you don't have default table. 3. with check optino you can use check option to use update and insert in the selected area 4. with read only you cannot edit the view with CRUD oper...

(오라클) Sequence/시퀸스의 활용과 개념

이미지
"왜 우린 오라클에서 시퀸스를 써야하는가?" 매일 오라클 사용자가 insert을 써서, 값을 일일이 타이핑 하는것도 노가다다. 우리 인간은 똑똑하기 때문에, sequence라는 걸 만들어서 자동화가 되게 만들었다. 간단한 규칙과 몇개의 숫자면 자동화가 된다는 얼마나 time-saving이라는 것 인가. 수학이랑 똑같다. 1, 2 , 3, 4, 5, 6...100 이 시퀸스를 보면 무슨 생각이 드는가? 수학적으로 해석하면, 1부터 시작, 100이 끝 +1 만큼 순환 x 이걸 우리는 영어로 쓸것이다. "시퀸스는 어떻게 써야하는가?" 아무 계정에서, create table 을 해서 sequence 을 만들것이다. create table emp01(     empNo number(13) primary key,       name varchar2(50) not null,     hire_date date ); sequence을 만드는 방법이 두가지가 있는데, 하나는 일일히 입력해서 만드는 것이고, create sequence emp_SEQ minvalue 1 //최솟값 maxvalue 999999999999999999 // 최대값 increment by 10 //증가값 start with 10 //10부터 시작 nocycle; //주기 없음 또 하나느 테이블을 펼쳐서 시퀸스를 눌러주고, 값을 입력해주면 된다. 시퀸스-> 오른쪽 마우스 클릭 -> 새 시퀸스 테이블에서 행을 집어넣을때 insert으를 쓴다 insert into emp01(empNo, name, hire_date) values(emp_SEQ.nextval,  'lucky', sysdate); 시퀸스에서 다른 insert 처럼 값을 바꿔서 넣지 않아도 된다 왜냐하면, 시퀸스에서 lucky란 이름은 중복되어도 되서 ...

(오라클+자바) 데이타베이스에 데이타 변경 하는 프로그램 만들기

이미지
We will make a program to edit the database in the oracle with the help of java. This will be our program templates. We will gonna make package and class like this. EmpMain In the main, we gonna introduce our first sentence in our program. We use switch ... case () sentence to build our front page of our program. if you enter 1 -> the prg will activate InsertEmp(); if you enter 2 -> the prg will activate UpdateEmp(); if you enter 3 -> the prg will activate SelectEmp(); if you enter 4 -> the prg will activate DeleteEmp(); if you enter nth -> the prg will go back to the first page of our program. EmpProcess This is prg foundation to act as a branch between main and insert/delete/update/select .  EmpDAO url is to oracle through IP address. uid and pwd is for oracle's account name and password, that you have already created. publuc EmpDAO is the must to write. pstmt = con.prepareStatement("insert (?,?,?,?,sysdate,?)...