CAFE

1.SQL 수업

Re: 🟥 오늘의 마지막 문제1 + 이수자 평가 8번 문제

작성자23기_홍재석|작성시간26.06.08|조회수17 목록 댓글 0

drop table sales;

create table sales
(   product_id    number(10) not null,
    customer_id   number(10) not null,
    quantity_sold number(10,2) not null,
    price         number(10,2) not null);
    
insert into sales(product_id, customer_id, quantity_sold, price) --임의로 데이터 입력하기
 values(1101, 108, 7, 25000);
 
insert into sales(product_id, customer_id, quantity_sold, price) --임의로 데이터 입력하기
 values(1200, 133, 25, 17000);
 
insert into sales(product_id, customer_id, quantity_sold, price) --임의로 데이터 입력하기
 values(1304, 251, 31, 20000); 

drop table mysales;
create table mysales(product_id, customer_id, quantity_sold, price_)
as
 select product_id, customer_id, quantity_sold, price from sales
 where 1 = 2;
 
select * from mysales;
desc mysales;

 

실행결과:

PRODUCT_ID NOT NULL NUMBER(10)
CUSTOMER_ID NOT NULL NUMBER(10)
QUANTITY_SOLD NOT NULL NUMBER(10,2)
PRICE_ NOT NULL NUMBER(10,2)

 

실행결과를 통해 NOT NULL 제약이 옮겨짐을 알 수 있으며

또한 mysales 테이블 생성 당시 1=2를 내걸은 것은 sales에서 mysales로 옮겨지는 데이터는 컬럼 외 없음을 의미함

(1=2는 성립 불가능하므로)

답 : A, C

 

다음검색
현재 게시글 추가 기능 열기

댓글

댓글 리스트
맨위로

카페 검색

카페 검색어 입력폼