Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- XML
- data structure
- for
- mysql
- computer
- github
- DATAPATH
- DS
- Java
- system
- control
- python
- javascript
- DoM
- php
- html
- MacOS
- Class
- web
- architecture
- MIPS
- DB
- Linux
- Algorithm
- Pipelining
- CSS
- react
- function
- instruction
- while
Archives
- Today
- Total
YYYEJI
[MySQL] DDL이란? 본문
728x90
DDL이란?
✓ Data Definition Language
✓ 필드 타입
• 정수형 - tinyint, smallint, int
• 실수형 - decimal, float, double
• 문자형 - char(n), varchar(n), text
• 날짜형 - date, time, date time, timestamp
char(n) vs varchar(n)
• char(n) - n만큼 데이터 공간 고정해 놓는다.
• varchar(n) - n은 max 데이터 공간으로 데이터의 공간이 가변적으로 줄었다 늘었다할 수 있다.
예제를 살펴봅시다.
CREATE TABLE tablename{
column1 int auto_increment,
column1 datatype,
column2 datatype not null,
column3 datatype default '0',
...
primary key(column1)
);
한 줄씩 살펴봅시다.
column1 int auto_increment,
✓ auto_increment 일련 번호를 넣지 않아도 자동으로 데이터를 하나씩 증가 시켜줍니다.
column1 datatype,
column2 datatype not null,
✓ not null은 column2의 공간이 null이 될 수 없다는 뜻입니다.
✓ 반대로 not null이 없으면 빈 공간으로 냅둬도 허용한다는 뜻입니다.
column3 datatype default '0',
✓ default '0'는 데이터가 들어오지 않으면 '0'으로 처리하겠다는 뜻이다.
primary key(column1)
✓ primary key 를 지정해줍니다.
예를 들어
• 학생의 경우는 학번,
• 일반 사람의 경우는 주민등록번호
입니다.
◡̈
'Database & SQL' 카테고리의 다른 글
[MySQL] SQL wildcards(LIKE) 정리 (0) | 2022.12.05 |
---|---|
[MySQL] DML이란? (0) | 2022.10.26 |
[DB] SQL이란? (0) | 2022.10.26 |
[DB] Database란? (0) | 2022.10.26 |
[DB] FILE와 DATABASE의 차이점 (0) | 2022.10.26 |