데이터 베이스 생성
CREATE DATABASE [만들 데이터베이스 이름];
유저 생성
create user [유저 이름] @ localhost identfied by '[비번]';
모든 권한 부여
grant all privaileges on [만든 데이터베이스 이름].* to [유저 이름]@localhost
작업할 데이터베이스를 선택
USE [데이터베이스 이름];
현재 데이터베이스가 무엇인지 확인
SELECT database();
컬럼명과 type을 볼수 있다
show columns from [테이블 이름];
또는 DESC [테이블 이름];
테이블 종류 확인
show tables;
테이블 삭제
DROP TABLE [테이블 이름];
Not null
create table [테이블 이름]
(
[컬럼명] 타입 not null,
[컬럼명] 타입 not null
);
ex) create table cats2
(
name varchar(100) not null,
age int not null
);
DEFAULT
create table [테이블이름](
[컬럼명] 타입 default 고정값,
[컬럼명] 타입 default 고정값
);
ex) create table cats3(
name varchar(50) default 'mystery',
age int default 99
);