alter table 테이블 이름 add 컬럼이름 자료형;
create table newBook(
bookid number not null,
bookname varchar2(20) not null,
publisher varchar2(20),
price number
);
// ORA-01400 오류 발생
// 원인 not null안에 null을 넣으려고 해서 발생하는 오류
insert into newBook values(1, null, '코스타미디어', 30000);
insert into newBook values(null, '신나는 자바', null, null);
// unique 제약
drop table newBook;
create table newBook(
bookid number unique,
bookname varchar2(20) not null,
publisher varchar2(20),
price number
);
insert into newBook values(1, '재밌는 자바', '코스타미디어', 30000);
// ORA-00001: 무결성 제약 조건(C##MADANG.SYS_C008366)에 위배됩니다
// bookid는 유일값인데 중복된 값을 넣어서 에러 발생
insert into newBook values(1, '신나는 자바', null, null);
create table newBook(
bookid number primary key,
bookname varchar2(20) not null,
publisher varchar2(20) default '코스타미디어',
price number
);
insert into newBook values(1, '재미있는 자바', '한빛미디어', 5000);
insert into newBook values(2, '신나는 자바', '코스타미디어', 5000);
insert into newBook (bookid, bookname) values(3, '재미있는 자바');
create table newBook(
bookid number primary key,
bookname varchar2(20) not null,
publisher varchar2(20) default '코스타미디어',
price number check (price >= 1000)
);
insert into newBook values(1, '재미있는 자바', '한빛미디어', 5000);
// ORA-02290: 체크 제약조건(C##MADANG.SYS_C008384)이 위배되었습니다
insert into newBook values(2, '재미있는 자바', '한빛미디어', 900);
create table newBook(
bookid number primary key,
bookname varchar2(20) not null,
publisher varchar2(20),
price number
);
insert into newBook values(1, '재밌는 자바', '코스타미디어', 30000);
// ORA-00001: 무결성 제약 조건(C##MADANG.SYS_C008366)에 위배됩니다
insert into newBook values(1, '재밌는 공부', '코스타미디어', 30000);
// ORA-01400 오류 발생
insert into newBook values(null, '재밌는 자바', '코스타미디어', 30000);
값의 수와 순서는 테이블의 구조와 동일해야 한다.
나열한 컬럼대로 맞춰야 한다.
drop table 테이블이름;