V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
fangwenxue
V2EX  ›  问与答

postgresql 字段默认值?

  •  
  •   fangwenxue · 2020-07-23 11:40:31 +08:00 · 1123 次点击
    这是一个创建于 1366 天前的主题,其中的信息可能已经有所发展或是发生改变。
    CREATE TABLE test (
    	ip inet,
    	port integer not null default 0,
    	country char(10) not null default '',
    	PRIMARY KEY(ip)
    )
    insert into test (ip, port) values('1.1.1.1', 80)
    

    结果 country 里面有 10 个空字符. 这是为啥?

    2 条回复    2020-07-23 11:47:02 +08:00
    ooh
        1
    ooh  
       2020-07-23 11:45:42 +08:00
    char 长度固定,长度不足的话空格补上
    optional
        2
    optional  
       2020-07-23 11:47:02 +08:00 via iPhone
    pg 无脑 text
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3571 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 04:39 · PVG 12:39 · LAX 21:39 · JFK 00:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.