【问题标题】:Cast text to numeric in sqlite table definition在 sqlite 表定义中将文本转换为数字
【发布时间】:2012-02-06 23:52:51
【问题描述】:

sqlite 中是否有强制转换,我需要它在创建表定义中工作...

....
mydatetime numeric not null DEFAULT (strftime('%Y%m%d%H%M','now', 'localtime')) );

谢谢

【问题讨论】:

    标签: sqlite casting create-table


    【解决方案1】:
    sqlite> .headers on
    sqlite> CREATE TABLE t1 (mydatetime int not null DEFAULT (strftime('%Y%m%d%H%M',
    'now', 'localtime')), otherval TEXT);
    sqlite>
    sqlite> INSERT INTO t1 (otherval) VALUES ('qwe');
    sqlite> SELECT * FROM t1;
    mydatetime|otherval
    201201231947|qwe
    

    【讨论】:

      猜你喜欢
      • 2012-12-27
      • 1970-01-01
      • 2012-09-07
      • 2019-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-29
      • 1970-01-01
      相关资源
      最近更新 更多