mysql5 7計算列的一些使用例項

2021-09-29 15:49:44 字數 1967 閱讀 2251

create table `fa_parent_goods`  (

`id` mediumint(11) not null auto_increment comment '商品id',

`goods_name` varchar(255) character set utf8 collate utf8_general_ci null default null comment '商品名稱',

`images` text character set utf8 collate utf8_general_ci null comment '產品',

`content` text character set utf8 collate utf8_general_ci null comment '詳情',

`qun_id` int(10) null default null comment '社群id',

`time_json` text character set utf8 collate utf8_general_ci null comment '預定時間設定',

`create_time` int(10) null default null,

`is_pg` tinyint(1) null default 0 comment '是否拼購',

`audit` tinyint(1) null default 0 comment '審核 0待審核1通過 2駁回',

`update_time` int(10) null default null,

`sales` smallint(5) null default 0 comment '銷量',

`min_tgprice` decimal(10, 2) null default 0.00 comment '最小**價',

`min_pgprice` decimal(10, 2) null default 0.00 comment '最小拼購價',

`min_price` decimal(10, 2) generated always as (least(`min_tgprice`,`min_pgprice`)) virtual null

`validate_switch` tinyint(4) null default null comment '是否設定有效時間',

primary key (`id`) using btree

) engine = innodb auto_increment = 0 character set = utf8 collate = utf8_general_ci comment = '商品表' row_format = compact;

set foreign_key_checks = 1;

alter table `yz`.`fa_parent_goods_copy1`

add column `min_price` decimal(10, 2) generated always as (least(`min_tgprice`,`min_pgprice`)) virtual null

create table log_sync_plan_data(

planlogid bigint primary key not null auto_increment,

synctype int not null default 0,

tablescnt int not null,

finishedcnt int not null default 0,

begintime datetime not null default now(),

endtime datetime not null default '1900-01-01',

elapsedseconds int generated always as (case when endtime'' or tablescnt<>finishedcnt then 0 else 1 end) virtual

);

mysql 5 7遇到的一些坑

1.在安裝過後 根目錄下沒有my.ini,可以選擇自行新建 mysql 設定mysql客戶端預設字符集 default character set utf8 mysqld 設定3306埠 port 6606 設定mysql的安裝目錄 basedir c program files x86 mysql...

MySQL 5 7中的更多改進,包括計算列

讓我們繼續上一周的內容,討論mysql 5.7中的新特性,我們將把注意力集中於新的安全方面的特性。首先,新版本中取消了mysql old password這個認證外掛程式。其實這個外掛程式從版本4.x開始就已經被標註為過期了,但直到5.7.5版本中才被正式移除。從5.7.6開始,你必須顯式地在mys...

MySQL 5 7中的更多改進,包括計算列

讓我們繼續上一周的內容,討論mysql 5.7中的新特性,我們將把注意力集中於新的安全方面的特性。首先,新版本中取消了mysql old password這個認證外掛程式。其實這個外掛程式從版本4.x開始就已經被標註為過期了,但直到5.7.5版本中才被正式移除。從5.7.6開始,你必須顯式地在mys...