How to store more than 255 char in MySQL database?

前端 未结 4 2051
死守一世寂寞
死守一世寂寞 2020-12-08 07:15

I only get set the text field in MySQL to 255, if I want to store a data longer than 255 chars, what can I do?

4条回答
  •  悲&欢浪女
    2020-12-08 08:19

    Use TEXT datatype:

    CREATE TABLE t_text (value TEXT NOT NULL);
    
    INSERT
    INTO    t_text
    SELECT  RPAD('', 1000, '*');
    
    SELECT  LENGTH(value)
    FROM    t_text;
    
    ---
    
    1000
    

提交回复
热议问题