쿼리문 임시저장

황인성·2023년 4월 13일
0

쿼리

CREATE DATABASE you1;

DROP DATABASE you1;



CREATE TABLE `account` (
	`account_id`	BIGINT	NOT NULL AUTO_INCREMENT,
	`user_nickname`	VARCHAR(255)	NOT NULL,
	`password`	VARCHAR(255)	NOT NULL,
	`user_email`	VARCHAR(255)	NOT NULL,
	`created_at`	DATETIME	NOT NULL,
	`birth`	VARCHAR(255)	NULL,
	PRIMARY KEY (account_id)
);

DROP TABLE `post`;

CREATE TABLE `post` (
	`post_id`	BIGINT	NOT NULL AUTO_INCREMENT,
	`title`	VARCHAR(255)	NOT NULL,
	`content`	VARCHAR(255)	NULL,
	`created_at`	DATETIME	NOT NULL,
	`modified_at`	DATETIME	NOT NULL,
	`hit`	BIGINT UNSIGNED	NOT NULL ,
	`like`	BIGINT UNSIGNED	NOT NULL ,
	`account_id`	BIGINT	NOT NULL,
	PRIMARY KEY (post_id),
	FOREIGN KEY (account_id) REFERENCES `account` (account_id)
);

DROP TABLE `comment`;

CREATE TABLE `comment` (
	`comment_id`	BIGINT	NOT NULL AUTO_INCREMENT,
	`comment`	VARCHAR(255)	NOT NULL,
	`created_at`	DATETIME	NOT NULL,
	`modified_at`	DATETIME	NOT NULL,
	`account_id`	BIGINT	NOT NULL,
	`post_id`	BIGINT	NOT NULL,
	PRIMARY KEY (comment_id),
	FOREIGN KEY (account_id) REFERENCES `account` (account_id),
	FOREIGN KEY (post_id) REFERENCES `post` (post_id)
);

DROP TABLE `mapping`;

CREATE TABLE `mapping` (
        `categories_id`	BIGINT	NOT NULL,
	`post_id`	BIGINT	NOT NULL,
	`nation_id`	BIGINT	NOT NULL,
	PRIMARY KEY (categories_id)
);

CREATE TABLE `nation` (
	`nation_id`	BIGINT UNSIGNED	NOT NULL AUTO_INCREMENT,
	`nation_name`	VARCHAR(255)	NOT NULL,
	PRIMARY KEY (nation_id)
);

SELECT * FROM `account`;

SELECT * FROM `post`;

SELECT * FROM `comment`;

SELECT * FROM `mapping`;

SELECT * FROM `nation`;


DESC ACCOUNT;

DESC post;

DESC COMMENT;

DESC mapping;

DESC nation;
profile
문제 해결을 위해 끊임없이 파고드는 걸 좋아합니다.

0개의 댓글