본문 바로가기

SQL22

SQL 연습문제 답 -- 테이블 삭제하는 명령어 delete drop truncate-- delete 용량 변경 없이 데이터만 삭제-- truncate 데이터, 용량, 인덱스 삭제-- drop 테이블 전체 삭제 Main querySubquery 올 수 있는 위치 : update_ set where -- (1)박지성이 구매한 도서의 출판사와 같은 출판사에서 도서를 구매한 고객의 이름select s1.name,s3.publisherfrom customer s1, orders s2, book s3 where s1.custid = s2.custid and s2.bookid = s3.bookid and s1.name != '박지성' and s3.publisher in (select publisher from customer t1, .. 2018. 3. 6.
[SQL] DDL, DML이란? DDL (데이터 정의 언어) DDL은 데이터베이스 구조를 정의하거나 조작하기 위한 SQL 명령어입니다. 이러한 명령어들을 사용하여 테이블, 인덱스, 뷰 등 데이터베이스의 구조를 생성, 변경 또는 삭제할 수 있습니다. DDL 명령어는 데이터베이스의 스키마를 정의하는 데 사용됩니다. 일반적인 DDL 명령어의 예시: CREATE: 새로운 데이터베이스 객체(테이블, 뷰, 인덱스 등)를 생성합니다. ALTER: 이미 존재하는 데이터베이스 객체의 구조를 변경합니다. DROP: 데이터베이스 객체를 삭제합니다. TRUNCATE: 테이블의 모든 데이터를 삭제합니다. RENAME: 데이터베이스 객체의 이름을 변경합니다. 예시: CREATE TABLE Employees ( ID INT PRIMARY KEY, Name VAR.. 2018. 3. 5.
[SQL] p.193 연습문제 -- 1.(5)박지성이 구매한 도서의 출판사 수 select count(distinct publisher) as "출판사 수"from customer t1, orders t2, book t3where t1.custid = t2.custid and t2.bookid = t3.bookid and t1.name = '박지성'; --1.(6)박지성이 구매한 도서의 이름, 가격, 정가와 판매가격의 차이select t3.bookname as 이름, t3.price as 가격, t3. price - t2.saleprice as 차액from customer t1, orders t2, book t3where t1.custid = t2.custidand t2.bookid = t3.bookidand t1.name = '박지.. 2018. 3. 2.
Oracle SQL 마당 SQL select * from book; // * 모든 book 출력select * from customer; // * 모든 customer 출력select * from orders; // * 모든 orders 출력select * from imported_book; // * 모든 imported_book 출력select bookid, bookname from book where price >= 10000; // 10000원 이상 ~~ 출력select bookid, bookname from book where bookname like '%축구%' and price 2018. 2. 12.