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 );