How to update all records of all tables in database?

Rahul

I have a table with a lot of records (could be more than 500 000 or 1 000 000). I want to update some common columns with the same field name in all tables throughout the database.

I know the traditional way to write separate queries to individual tables but not one query to update all records of all tables.

What is the most efficient way to do this in SQL, without using some dialect-specific features, so it works everywhere (Oracle, MSSQL, MySQL, Postgres etc.)?

ADDITIONAL INFO: There are no calculated fields. There are indexes. Used generated SQL statements that update the table row by row.

Rick James

(This sounds like the classic case for normalizing that 'column'.)

Anyway... No. There is no single query to locate that column across all tables, then perform an UPDATE on each of the tables.

In MySQL, you can use the table information_schema.COLUMNS to locate all the tables containing a particular named column. With such a SELECT, you can generate (using CONCAT(), etc) the desired UPDATE statements. But then, you need to manually run them (via copy and paste).

Granted, you could probably write a Stored Procedure to wrap that into a single call, but that is too risky. What if some other table has the same column name, but should not be updated?

As for common code across multiple vendors -- forget it! Virtually every syntax needs some amount of tweaking.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How To Delete All Records From Database All Tables

From Dev

How to export into a file all records from the tables of a database ?

From Dev

How to export into a file all records from the tables of a database ?

From Dev

How to show all records from 2 tables in same database?

From Dev

How to return all records from all tables?

From Dev

How to update a specific characters of column value for all tables in a database

From Dev

How to update all tables in a SQL Server database using a Loop

From Dev

How to update all cells in all tables with datatable

From Dev

How to search all tables in a database?

From Dev

Add after Update trigger to all tables in database

From Dev

Update Datetime Values in all the Tables in the database

From Dev

how to list all TABLES(not records) of a database in a drop down list MySQL PHP

From Dev

Update all unique records (compare a field in 2 different tables)

From Dev

How to update all client records from CloudKit?

From Dev

How to Update a column of all duplicate records in mysql?

From Dev

How to read all the records of mnesia database in erlang?

From Dev

update all records on cakephp

From Dev

How to index rebuild in MySQL for all tables in a database?

From Dev

SQLite: How to add a column to all the tables in the database?

From Dev

List all tables in database

From Dev

Query All Tables In A Database

From Dev

one sql trigger insert,update,delete for all tables in the database

From Dev

one sql trigger insert,update,delete for all tables in the database

From Dev

Getting last user update time for all tables in a database

From Dev

Delete all records from all tables in database using seeds.rb

From Dev

How to Retrieve All Tables From SQL Database (Excluding System Tables)

From Dev

MySQL - How to select records that match all IN values but in 1 or more tables

From Dev

MySQL - How to select records that match all IN values but in 1 or more tables

From Dev

How to show all the records from both tables With unmatched record also?

Related Related

  1. 1

    How To Delete All Records From Database All Tables

  2. 2

    How to export into a file all records from the tables of a database ?

  3. 3

    How to export into a file all records from the tables of a database ?

  4. 4

    How to show all records from 2 tables in same database?

  5. 5

    How to return all records from all tables?

  6. 6

    How to update a specific characters of column value for all tables in a database

  7. 7

    How to update all tables in a SQL Server database using a Loop

  8. 8

    How to update all cells in all tables with datatable

  9. 9

    How to search all tables in a database?

  10. 10

    Add after Update trigger to all tables in database

  11. 11

    Update Datetime Values in all the Tables in the database

  12. 12

    how to list all TABLES(not records) of a database in a drop down list MySQL PHP

  13. 13

    Update all unique records (compare a field in 2 different tables)

  14. 14

    How to update all client records from CloudKit?

  15. 15

    How to Update a column of all duplicate records in mysql?

  16. 16

    How to read all the records of mnesia database in erlang?

  17. 17

    update all records on cakephp

  18. 18

    How to index rebuild in MySQL for all tables in a database?

  19. 19

    SQLite: How to add a column to all the tables in the database?

  20. 20

    List all tables in database

  21. 21

    Query All Tables In A Database

  22. 22

    one sql trigger insert,update,delete for all tables in the database

  23. 23

    one sql trigger insert,update,delete for all tables in the database

  24. 24

    Getting last user update time for all tables in a database

  25. 25

    Delete all records from all tables in database using seeds.rb

  26. 26

    How to Retrieve All Tables From SQL Database (Excluding System Tables)

  27. 27

    MySQL - How to select records that match all IN values but in 1 or more tables

  28. 28

    MySQL - How to select records that match all IN values but in 1 or more tables

  29. 29

    How to show all the records from both tables With unmatched record also?

HotTag

Archive