fangwenxue
V2EX  ›  问与答

postgresql 字段默认值?

  •  
  •   fangwenxue · Jul 23, 2020 · 1912 views
    This topic created in 2294 days ago, the information mentioned may be changed or developed.
    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 replies  •  2020-07-23 11:47:02 +08:00
    ooh
    ooh
    Jul 23, 2020
    1
    char 长度固定,长度不足的话空格补上
    optional
    optional
    Jul 23, 2020 via iPhone
    2
    pg 无脑 text
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2659 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 14:22 · PVG 22:22 · LAX 06:22 · JFK 09:22
    ♥ Do have faith in what you're doing.