首页 > 数据库 >mysql数据库运行sql:datetime(0) NULL DEFAULT NULL报错【杭州多测师_王sir】

mysql数据库运行sql:datetime(0) NULL DEFAULT NULL报错【杭州多测师_王sir】

时间:2023-09-01 15:34:50浏览次数:42  
标签:sir 00 01 utf8mb4 DEFAULT datetime 报错 NULL

 

一、错误信息

CREATE TABLE `file`  (
  `id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '文件md5',
  `name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `create_time` datetime(0) NULL DEFAULT NULL,
  `update_time` datetime(0) NULL DEFAULT NULL,,
  PRIMARY KEY (`id`)
)

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(0) NULL  DEFAULT NULL,
  `update_time` datetime(0) NULL DEFAULT NULL,
  `tena' at line 3

 

二、解决方法

问题发现是第三行,那就是datetime字段,在网上查询是mysql版本时间字段不能设置为0。给一个默认值,直接删除 (0) NULL

CREATE TABLE `file`  (
  `id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '文件md5',
  `name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  ##默认是1970-01-01 00:00:00,中国时间要加8
  `create_time` datetime DEFAULT '1970-01-01 08:00:00',
  `update_time` datetime DEFAULT '1970-01-01 08:00:00',
  PRIMARY KEY (`id`)
)

 

标签:sir,00,01,utf8mb4,DEFAULT,datetime,报错,NULL
From: https://www.cnblogs.com/xiaoshubass/p/17671990.html

相关文章

  • The specified target project directory xxxx does not exist 报错
    检查generatorConfig.xml中targetProject属性是否为相对路径原因:targetProject属性中的相对路径无法找到   文件路径是由启动类的Workingdirectory+targetProject决定的所以xml文件中的targetProject属性需要,以绝对路径-Workingdirectory路径=相......
  • centos里phpstudy报错
    出现Addressalreadyinuse:AH00072:make_sock:couldnotbindtoaddress[::]:8报错,说明80端口被占用可以寻找到80端口使用的程序并关闭。但是我当时查看线程和端口的时候没有找到。这台虚拟机之前安装过apache,所以systemctlstophttpd解决。......
  • OGG_Linux_x64_BigData启动ggsci时报错:error while loading shared libraries: libjvm
    问题描述:[root@hadoop03ggs]$./ggsci./ggsci:errorwhileloadingsharedlibraries:libjvm.so:cannotopensharedobjectfile:Nosuchfileordirectory 解决办法:1.查看缺少那些.so文件[root@hadoop03/]# lddggsci 2.查libjvm.so库文件的路径[root@hadoop0......
  • 随身WiFi安装青龙面板通用依赖安装及部分报错解决方法
    使用方法:到青龙面板--依赖管理--新建依赖依赖类型选择对应名称一键复制下面的依赖,粘贴到名称可填写框框记得选自动拆分NodeJs依赖库crypto-jsprettytabledotenvjsdomdate-fnstough-cookietslibws@7.4.3ts-md5jsdom-gjiebafsform-datajson5global-agentpng-js@ty......
  • node18 vue2启动报错 error:0308010C:digital envelope routines::unsupported
    出现原因貌似是因为是因为node17版本开始发布的OpenSSL3.0,而OpenSSL3.0对允许算法和密钥大小增加了严格的限制,可能会对生态系统造成一些影响。解决方法第一种方法降低node版本降低到17以下即可,如项目不能降低版本看后面的解决方式第二种方法设置NODE_OPTIONS环境变量......
  • python selenium报错ValueError: Timeout value connect was <...>, but it must be an
    最近学习爬虫,安装selenium,很简单地执行代码,但是一直报错。importtimeimportopenpyxlfromseleniumimportwebdriverfromselenium.webdriver.common.keysimportKeysfromselenium.webdriver.common.byimportByfromselenium.webdriver.chrome.serviceimportService......
  • Centos误删系统自带python2.7,yum报错恢复方法
     使用wget分别下载python以及yum的rpm包资源地址如下:          http://vault.centos.orgmkdir/usr/local/src/pythoncd/usr/local/src/pythonwgethttp://vault.centos.org/7.6.1810/os/x86_64/Packages/python-backports-1.0-8.el7.x86_64.rpmwgethtt......
  • python3.6使用wordcloud 1.9报错ValueError: Only supported for TrueType fonts
    该版本的wordcloud的源码中显示不兼容python3.6 解决办法:修改wordcloud源码修改前508:box_size=draw.textbox((0,0),word,font=transposed_font,anchor="lt")510:result=occupancy.sample_position(box_size[3]+self.margin,......
  • 【Python】报错处理笔记
    shutil.rmtree(path)报错:PermissionError:[WinError5]分析:对应的目录或文件被设置了只读属性解决方案:defremove_readonly(func,path,_):#错误回调函数,改变只读属性位,重新删除"Clearthereadonlybitandreattempttheremoval"os.chmod(path,stat.S_I......
  • Mybatis Plus报错: can not find lambda cache...
    使用mybatisplus时使用Lambda表达式做查询条件会遇到mybatis拿不到缓存问题:错误1:com.baomidou.mybatisplus.core.exceptions.MybatisPlusException:cannotfindlambdacacheforthisentity错误2:cannotfindlambdacacheforthisproperty[XXX]ofentity[com.XXX.X......