일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 |
Tags
- aqqle
- Elasticsearch
- aggs
- 양자컴퓨터
- IONQ
- java crawler
- Query
- Cache
- dbeaver
- mysql
- TSLA
- api cache
- Aggregation
- request cache
- 테슬라
- Analyzer
- JPA
- Selenium
- 아이온큐
- API
- java
- KNN
- Elastic
- redis
- Docker
- elasticsearch cache
- file download
- NORI
- vavr
- ann
Archives
- Today
- Total
아빠는 개발자
[Aqqle] SQL 본문
728x90
반응형
-- shop.stock definition
CREATE TABLE `goods_tmon` (
`id` bigint NOT NULL AUTO_INCREMENT,
`keyword` varchar(200) DEFAULT NULL,
`name` varchar(500) NOT NULL,
`price` bigint NOT NULL,
`weight` float NOT NULL,
`popular` float NOT NULL,
`image` varchar(400) DEFAULT NULL,
`feature_vector` text NOT NULL,
`type` varchar(50) NOT NULL,
`created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `updated_time_index` (`updated_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
CREATE TABLE `members` (
`id` bigint NOT NULL AUTO_INCREMENT,
`user_id` varchar(200) NOT NULL,
`name` varchar(200) NOT NULL,
`use_yn` enum('Y','N') NOT NULL DEFAULT 'Y',
`created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
CREATE TABLE `users` (
`id` bigint NOT NULL AUTO_INCREMENT,
`user_id` varchar(200) NOT NULL,
`name` varchar(200) NOT NULL,
`use_yn` enum('Y','N') NOT NULL DEFAULT 'Y',
`created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
CREATE TABLE `keywords` (
`id` bigint NOT NULL AUTO_INCREMENT,
`keyword` varchar(200) NOT NULL,
`use_yn` enum('Y','N') NOT NULL DEFAULT 'Y',
`created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `keyword_index` (`keyword`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `aqqle_goods` (
`id` bigint NOT NULL AUTO_INCREMENT,
`keyword` varchar(200) DEFAULT NULL,
`brand` varchar(500) DEFAULT NULL,
`category` varchar(2000) DEFAULT NULL,
`category1` varchar(200) DEFAULT NULL,
`category2` varchar(200) DEFAULT NULL,
`category3` varchar(200) DEFAULT NULL,
`category4` varchar(200) DEFAULT NULL,
`category5` varchar(200) DEFAULT NULL,
`name` varchar(500) NOT NULL,
`price` bigint NOT NULL,
`weight` float NOT NULL,
`popular` float NOT NULL,
`image` varchar(400) DEFAULT NULL,
`feature_vector` text NOT NULL,
`type` varchar(50) NOT NULL,
`created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `updated_time_index` (`updated_time`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `investment` (
`id` bigint NOT NULL AUTO_INCREMENT,
`company` varchar(200) NOT NULL,
`exchange` varchar(200) NOT NULL,
`type` varchar(20) NOT NULL,
`price` bigint NOT NULL default 0,
`quantity` bigint NOT NULL default 0,
`use_yn` enum('Y','N') NOT NULL DEFAULT 'Y',
`created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `company_index` (`company`,`exchange` )
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- TRUNCATE table stock
CREATE TABLE `stock` (
`id` bigint NOT NULL AUTO_INCREMENT,
`company` varchar(100) NOT NULL,
`company_code` varchar(20) NOT NULL,
`exchange` varchar(30) NOT NULL,
`start_date` date NOT NULL,
`end_date` date NOT NULL,
`type` varchar(20) NOT NULL,
`use_yn` enum('Y','N') NOT NULL DEFAULT 'Y',
`created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `company_code_index` (`company_code` )
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `stock_data` (
`id` bigint NOT NULL AUTO_INCREMENT,
`company` varchar(100) NOT NULL,
`company_code` varchar(20) NOT NULL,
`trading_date` date NOT NULL,
`open` float NULL,
`high` float NULL,
`low` float NULL,
`close` float NULL,
`adj_close` float NULL,
`volume` bigint NULL,
`created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`company_code`, `trading_date`),
UNIQUE KEY `unique_id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `stock_data_partition` (
`id` bigint NOT NULL AUTO_INCREMENT,
`company` varchar(100) NOT NULL,
`company_code` varchar(20) NOT NULL,
`trading_date` date NOT NULL,
`open` float DEFAULT NULL,
`high` float DEFAULT NULL,
`low` float DEFAULT NULL,
`close` float DEFAULT NULL,
`adj_close` float DEFAULT NULL,
`volume` bigint DEFAULT NULL,
`created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`company_code`,`trading_date`),
UNIQUE KEY `unique_id` (`id`, `trading_date`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
PARTITION BY RANGE (YEAR(trading_date)) (
PARTITION p0 VALUES LESS THAN (2021),
PARTITION p1 VALUES LESS THAN (2022),
PARTITION p2 VALUES LESS THAN (2023),
PARTITION p3 VALUES LESS THAN (2024),
PARTITION p4 VALUES LESS THAN (2025),
PARTITION p5 VALUES LESS THAN (MAXVALUE)
);
728x90
반응형
'Database' 카테고리의 다른 글
[DB] DBeaver - Public key retrieval is not allowed (0) | 2024.08.11 |
---|---|
[MySQL] Group by 결과로 sort, 여러 조건을 결과로 sort (0) | 2024.06.11 |
[database] DBeaver 다운로드 (0) | 2024.01.07 |
[MySQL] Ngram (1) | 2024.01.07 |
[MySql] MySQLWorkbench EER diagram 그리기 (0) | 2023.09.02 |