常用sql语句

  • 修改数据库字符集
ALTER DATABASE db_name DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
  • 从一张查询并插入新数据到另外一表,可以指定某个字段的值
INSERT INTO newtableName(col1, col2) SELECT column1, 'somevalue' as column2  FROM tableName;