Hi

I am wondering if i can move a field (with contents) from Table B to Table A. If so how can i do it?

Any advise ?? Thank you very much..

Dani AI

Generated

Yes — moving a column and its data from one table into another is normal and, as showed (and confirmed), it can be done safely. The basic idea is to add the column to the destination table, copy the values across, verify everything, then remove the old column. The following checklist highlights safe, practical steps and common pitfalls to avoid.

  1. Make a full backup of the affected tables before you start.
  2. Add the new column to Table A with the correct data type, length, collation, nullability and default.
  3. Copy values from Table B into Table A using a single targeted operation for small tables or batched updates for large ones. Decide ahead how to handle missing values.
  4. Verify: compare counts, sample rows, and run queries that confirm no unexpected NULLs or duplicates.
  5. If all checks pass, drop the column from Table B and adjust indexes or foreign keys as needed. Update any app code that still references the old column.

Notes and cautions:

  • If Table B can contain multiple rows per join-key (one-to-many), you must decide which value to keep (aggregate, first, latest) before moving.
  • Moving a column used in constraints, FKs, or as part of a primary/auto-increment key needs special handling. Do not drop constraints until referencing code/schema is updated.
  • ALTER TABLE is DDL and can implicitly commit; transactional semantics differ by storage engine (InnoDB vs MyISAM). See MySQL docs on ALTER TABLE and implicit commits: ALTER TABLE and Implicit commit behavior.

For very large tables or live production systems, consider online schema-change tools (for example, Percona’s pt-online-schema-change) or the copy-and-rename pattern to avoid long locks: pt-online-schema-change. Test the whole process on a copy first.

Recommended Answers

All 2 Replies

Hi

I am wondering if i can move a field (with contents) from Table B to Table A. If so how can i do it?

Any advise ?? Thank you very much..

yes, you can do it with the PHP Myadmin utility directly.Look for some option in the database for copying the field or/and data to some other table in the same or different database.
You can create the same field manually, if there is just one and copy the data like -

UPDATE table1
INNER
  JOIN table2
    ON table2.something = table1.something
   SET table2.field2 = table1.user

Thanks.. it works!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.