Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含一列整数数据类型的表。我想添加另一个具有字符串数据类型的列。
最后,我想将第一列中的值复制到第二列。这意味着我想从第一列复制整数数据并以字符串格式将其复制到第二列。
将列转换为 aCHAR将做你想做的事:
CHAR
UPDATE `table` SET column2 = CAST(column1 AS CHAR)
用于ALTER TABLE添加列。添加的语法是
ALTER TABLE
ALTER TABLE tablename ADD column_name datatype;
转移:
UPDATE tablename SET second_column = CAST(first_column AS CHAR);