CAFE

1.SQL 수업

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

작성자23기_서한결|작성시간26.06.08|조회수22 목록 댓글 0

Which two statements are true? (2개)

 

A. MYSALES is created with no rows.

B. MYSALES will have no constraints defined regardless of which constraints might be defined on SALES.

C. MYSALES has NOT NULL constraints on any selected columns which had that constraint in the SALES table.

D. MYSALES is created with 2 rows.

E. MYSALES is created with 1 row.

 

답 : A, C

 

 


 

 

CREATE TABLE sales  --- 테이블 생성
  (
     product_id     NUMBER(10) CONSTRAINT sales_product_id_nn NOT NULL,
     customer_id    NUMBER(10) CONSTRAINT customer_id_nn NOT NULL,
     quantity_sold  NUMBER(10, 2) CONSTRAINT quantity_sold_nn NOT NULL,             
     price          NUMBER(10, 2)
  );

INSERT INTO sales  --- 임의 데이터
  VALUES ( 1111, 222, 333, 444 );
  
INSERT INTO sales
  VALUES ( 1234, 22, 33, 44 );
  
INSERT INTO sales
  VALUES ( 4321, 22, 3, 4 );

CREATE TABLE mysales (prod_id, cust_id, quantity_sold, price)
AS
  SELECT product_id, customer_id, quantity_sold, price
  FROM sales
  WHERE 1 = 2;   --- 컬럼만  ( 답 A, C )

SELECT *
  FROM mysales;
  
INSERT INTO mysales --- NULL 제약조건 테스트
  VALUES ( 0987, 11, NULL , 33 );

 

 

 

 

 

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

댓글

댓글 리스트
맨위로

카페 검색

카페 검색어 입력폼