You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
-- 个股基础信息表:存储个股静态信息(低频变更)
CREATE TABLE ` t_stock_basic ` (
` stock_code ` VARCHAR ( 20 ) NOT NULL COMMENT ' 证券代码( 如000061.SZ、600000.SH) ' ,
` stock_name ` VARCHAR ( 50 ) NOT NULL COMMENT ' 证券名称(如“农 产 品”) ' ,
` listing_date ` DATE NULL COMMENT ' 首发上市日期 ' ,
` listing_days ` INT NULL COMMENT ' 上市天数(冗余存储,提升查询效率) ' ,
` is_st ` TINYINT ( 1 ) NOT NULL DEFAULT 0 COMMENT ' 是否为ST股票( 1=是, 0=否) ' ,
` is_star_st ` TINYINT ( 1 ) NOT NULL DEFAULT 0 COMMENT ' 是否为*ST股票( 1=是, 0=否) ' ,
` industry_index_code ` VARCHAR ( 20 ) NOT NULL COMMENT ' 所属行业指数代码( 关联t_industry_index) ' ,
` industry_index_name ` VARCHAR ( 50 ) NOT NULL COMMENT ' 所属行业指数名称(冗余存储,减少关联查询) ' ,
` create_time ` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ' 数据创建时间 ' ,
` update_time ` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT ' 数据更新时间 ' ,
-- 主键:证券代码唯一
PRIMARY KEY ( ` stock_code ` ) ,
-- 外键:关联行业指数表,确保行业代码有效性(禁止删除/修改主表已关联的行业代码)
FOREIGN KEY ( ` industry_index_code ` )
REFERENCES ` t_industry_index ` ( ` industry_index_code ` )
ON UPDATE RESTRICT ON DELETE RESTRICT ,
-- 索引:优化按行业筛选个股的场景
INDEX ` idx_t_stock_basic_industry ` ( ` industry_index_code ` )
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = ' A股个股基础信息 ' ;