전체 글 263

210831_update,delete

update --update: 수정 --update 테이블명 set 컬럼명1='바꿀내용', 컬럼명='바꿀내용' where 조건 --직업과 나이 수정하기..where조건 안 쓰면 전체 데이터 수정됨 update person set job='공무원',age=38; --잘못 수정한 데이터 되돌리기 rollback; --5번의 직업과 나이 수정하기 update person set job='공무원',age=38 where num=5; --전체 데이터 확인 select * from person; --저장 commit; --황씨이면서 세무사인 사람의 gender를 남자로 수정 update person set gender='남자' where name like '황%' and job='세무사'; --num이 12인 사람..

Oracle 2021.08.31

210831_to char

to_char to_char : date형, number형을 varchar2형으로 변환 to_date : char,varchar2형을 date타입으로 변환 (예제) --날짜에서 년도만 추출 select to_char(sysdate,'year') from dual; --영문으로 출력 select to_char(sysdate,'yyyy') from dual; --2021 --날짜에서 월만 추출 select to_char(sysdate,'month') from dual; --8월 select to_char(sysdate,'mm') from dual;--08 --날짜와 시간출력 alter session set time_zone='Asia/seoul'; --미국 시간으로 뜰 경우 해주기 select to_char..

Oracle 2021.08.31

210831_그룹함수

그룹함수 avg(salary) : salary의 평균 count(salary) : 행의 개수 max(salary) : salary의 최대값 min(salary) : salary의 최소값 stddev(salary) : salary의 표준편차 sum(salary) : salary의 총합 variance(salary) : salary의 분산 --기본적으로 이 함수들은 null값은 모두 무시하며 그룹함수는 where절로 제어할 수 없다. --평균나이 구하기 select avg(age) from person; --평균나이 구하기..소수점 1자리(round) select round(avg(age),1) from person; --나이 합계 select sum(age) from person; --전체 인원 구하기....

Oracle 2021.08.31

210831_sequence

--시퀀스 기본으로 생성, 1부터 1씩 증가하는 시퀀스 생성됨 create sequence seq1; --전체 시퀀스 확인 select * from seq; --다음 시퀀스 값을 발생해서 콘솔에 출력..nextval(dual은 콘솔을 의미) select seq1.nextval from dual; --현재 마지막 발생한 시퀀스값..currval select seq1.currval from dual; --seq1 시퀀스 삭제 drop sequence seq1; --10부터 5씩 증가하는 시퀀스 생성..cache 값은 없애기(no cache) create sequence seq1 start with 10 increment by 5 nocache; --다음 시퀀스 발생 select seq1.nextval fro..

Oracle 2021.08.31

210830_

--emp테이블 전체조회...ctrl+enter는 한줄조회 select * from emp; --emp테이블에서 급여가 작은사람부터 조회하되 ename,sal 만 조회 select ename,sal from emp order by sal asc;--asc는 생략가능 --emp테이블에서 급여가 큰사람부터 조회하되 ename,job,sal 만 조회 select ename,job,sal from emp order by sal desc; --emp테이블에서 job만출력 select job from emp; --emp테이블에서 job만출력(중복제거) select distinct job from emp; --alias 별칭주기_1 select ename "직원명",job "부서" from emp; --alias 별..

Oracle 2021.08.30

210826_Lamda

//람다 //자바의 함수형 프로그램인 람다 표현식은 인터페이스 사용하는 익명내부클래스의 또다른 표현식 //하지만 인터페이스가 단 하나의 추상메서드만 갖고 있어야 한다 그리서 사용 빈도 낮음 //추상메서드 interface Orange{ public void write(); //public void play(); 람다식 표현으로는 추상메서드 하나만 가능해서 두개 불가능 } public class Lamda_04 { //익명내부클래스 이용해서 오버라이딩 하기 public void abstMethod1() { Orange or=new Orange() { @Override public void write() { System.out.println("익명내부클래스의 오렌지 입니다"); } }; //출력 or.wri..

JAVA 2021.08.26

210826_Thread

(예제1) public class Thread_05 { //클래스를 상속받지 않고 그냥 해보기 String name; int num; public Thread_05(String name,int num) { this.name=name; this.num=num; } // //방법2 // @Override // public void run(){ // for(int i=0;i0 ~ three==>300 까지 출력됨 ~~~~~~~~~~~~~~~~~~~~~~~~~ (예제2) //Thread_05와 같으나 이번에는 인터페이스 구현해서 해보기 public class Thread_06 implements Runnable{ String name; int num; public Thread_06(String name,int ..

JAVA 2021.08.26

210824_Swing+Label+Button+Arrays+Random

public class SwingLabelGridEx05 extends JFrame { Container cp; JLabel[] lbl=new JLabel[9]; //공간만 할당받고 초기값 받은 거 아님 String []str={"한국","영국","프랑스","오스트리아","체코","헝가리","홍콩","미국","태국"}; JButton btn; public SwingLabelGridEx05(String title) { super(title); cp=this.getContentPane(); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setBounds(700,100,600,600); cp.setBackground(new Color(151,190,20..

Swing 2021.08.24

210823_Swing(버튼)+image+Arrays

public class SwingArraysBtn_09 extends JFrame{ Container cp; JButton[]btn=new JButton[6]; //배열선언, 6개 할당 String [] btnLabel= {"Red","Yellow","Blue","Gray","Pink","White"}; //버튼6개인걸 알기에 6개만 생성 Color [] btncolor= {Color.RED,Color.YELLOW,Color.BLUE,Color.GRAY,Color.PINK,Color.WHITE }; //컬러 각각의 번지수에 맞춰 작성 public SwingArraysBtn_09(String title) { super(title); cp=this.getContentPane(); this.setDefault..

JAVA 2021.08.23