V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
fangwenxue
V2EX  ›  问与答

postgresql 字段默认值?

  •  
  •   fangwenxue · Jul 23, 2020 · 1484 views
    This topic created in 2118 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
        1
    ooh  
       Jul 23, 2020
    char 长度固定,长度不足的话空格补上
    optional
        2
    optional  
       Jul 23, 2020 via iPhone
    pg 无脑 text
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3286 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 48ms · UTC 13:01 · PVG 21:01 · LAX 06:01 · JFK 09:01
    ♥ Do have faith in what you're doing.