MariaDB: Table commands

MariaDB Reference

Contents

  1. Move table to another database
  2. Insert from other table
  3. Update from other table
  4. Change auto-increment

Move table to another database


ALTER TABLE OldDatabase.TableName RENAME NewDatabase.TableName

Insert from other table


INSERT INTO TargetTable (TargetColumn)
SELECT SourceColumn FROM SourceTable

Update from other table


UPDATE TargetTable
LEFT JOIN SourceTable USING (...)
SET TargetColumn = ...

Change auto-increment


ALTER TABLE TableName AUTO_INCREMENT = Value