❤️MySQL插入数据
/* -- 创建表 CREATE TABLE `autocar_channel_cn_map` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `app_name` varchar(100) NOT NULL DEFAULT '' COMMENT 'app名称', `channel_id` varchar(100) NOT NULL DEFAULT '' COMMENT 'channel_id', `channel_name` varchar(100) NOT NULL DEFAULT '' COMMENT '频道中文名称', `log_channel_name` varchar(100) NOT NULL DEFAULT '' COMMENT 'sub_tab名称', `status` int(10) NOT NULL DEFAULT '0' COMMENT '频道是否已下线', `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', PRIMARY KEY (`id`), KEY `idx_channel_name` (`channel_name`), KEY `idx_channel_id` (`channel_id`) ) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8 COMMENT='渠道管理表' */ /* -- 插入表数据 INSERT INTO `autocar_channel_cn_map`( `app_name`, `channel_id`, `channel_name`, `log_channel_name`, `status`) VALUES ('automobile', '68604465163', '导购', 'motor_car_new_guide', 0), ('automobile', '58707071729', '视频', 'motor_car_video', 0); */ -- 首次插入 创建时间与更新时间默认为插入时间 /* -- 更改记录 update autocar_channel_cn_map set status = 1 where channel_name = '视频' */ -- 更改记录,更新时间会实时更新为最新更改时间 /* delete 并不删除表,只删除数据 delete from autocar_channel_cn_map where status = 1 -- 删除单条记录 delete from autocar_channel_cn_map -- 删除整个表的记录 */ /* -- 删除表 drop table autocar_channel_cn_map */
-- delete、truncate以及drop的区别 -- delete、truncate 都是只删除数据,不删除表,drop直接删除表 https://www.cnblogs.com/zhizhao/p/7825469.html https://blog.csdn.net/ywl470812087/article/details/88376129 https://zhidao.baidu.com/question/171481100.html https://blog.csdn.net/qq_28483283/article/details/81873054 https://blog.csdn.net/zhf_2016cs/article/details/52260063 https://blog.csdn.net/u010838785/article/details/98728627
-- 时间戳是以'1970-01-01 00:00:00' UTC 时间为起点,北京时间为+8时区,为'1970-01-01 08:00:00' 为起点,与起点的秒级差 -- select from_unixtime(0) -- 1970-01-01 08:00:00 【距离 1970-01-01 08:00:00 距离为0秒的日期 即起点日期】 -- select unix_timestamp('1970-01-01 08:00:00') -- 0 【获取这个日期距离起点的时间差(秒级别)】 -- timestamp的日期范围 -- select from_unixtime((power(2,31)-1)) -- 距离 1970-01-01 08:00:00 括号时长的日期 链接:https://blog.csdn.net/weixin_33841503/article/details/90253454
https://www.cnblogs.com/fps2tao/p/9039185.html
-- timestamp 和 datetime的区别 timestamp所能存储的时间范围为:'1970-01-01 00:00:01.000000' 到 '2038-01-19 03:14:07.999999' datetime所能存储的时间范围为: '1000-01-01 00:00:00.000000' 到 '9999-12-31 23:59:59.999999'
细说timestamp类型: timestamp占4个字节,存的时间戳,能存的时间范围为'1970-01-01 00:00:01' UTC 至'2038-01-19 03:14:07' UTC timestamp默认时间戳(Timestamp)类型的取值范围为'1970-01-01 00:00:01' UTC 至'2038-01-19 03:14:07' UTC,北京时间默认 +8小时(1970-01-01 08:00:01' 至 '2038-01-19 11:14:07') PS:插入超过都会报错:Incorrect datetime value 如:1970-01-01 08:00:00 和 2038-01-19 11:14:08 相关链接: https://blog.csdn.net/fsp88927/article/details/80662369