fangwenxue
V2EX  ›  问与答

postgresql 字段默认值?

  •  
  •   fangwenxue · Jul 23, 2020 · 1916 views
    This topic created in 2295 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   ·   1304 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 20:34 · PVG 04:34 · LAX 12:34 · JFK 15:34
    ♥ Do have faith in what you're doing.