1

I have a database that include many tables with have same column name and I would like to run a SQLITE3 query to change the values of all tables.

  Table XXX (id integer, name text);
  Table YYY (id integer, .....);
  Table ZZZ (id integer, .....);
  Table....

To run a query on all table which jave a field name "id" I used the query: select name from sqlite_master where sql like ('%id%');

But, how could I use the UPDATE query with the list of tables?

2
  • Can you give a more realistic example? Is this your actual situation? Commented Nov 24, 2013 at 19:16
  • I have a database which includes a default key value for all tables. I would like to change all default in all tables in one query. This key is not unique, there is other columns that are unique but all belong to same id. Commented Nov 24, 2013 at 19:24

2 Answers 2

1

Not possible with regular sql without simply listing all table/column combinations.

Possible solutions could be functions/procedures or other ways to execute dynamically generated sql.

Sign up to request clarification or add additional context in comments.

1 Comment

The list of tables that includes th "I'd" field is appear above. Select name from sqlite_master where.... But I need to include in update a list of tables and not one
0

You can use a trigger in order to update as many tables you want after insert in a single table .

example trigger

CREATE TRIGGER update_tables
AFTER INSERT ON XXX
BEGIN

INSERT INTO YYY (new.id,new.integer);
INSERT INTO ZZZ (new.id,new.integer);

END

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.