sql: update a given field in all tables instead of just one table

。_饼干妹妹 提交于 2019-12-24 09:18:55

问题


As per another question, sql: update a column if another column poses a conflict in namespace, we know that the following could be used to ensure that a set of 10000 unique package names and 100 categories, having 15000 unique combinations (thus table entries in table categories), could be updated to ensure that the two namespaces don't collide with one another (affecting about 10 entries in total):

UPDATE categories
SET fullpkgpath = fullpkgpath || ',pkg'
WHERE fullpkgpath IN (SELECT value
                      FROM categories)

However, the fullpkgpath field also repeats in other tables within my sqlite3 database, as per the schema.

  • Is there a way to have the above UPDATE statement applied to all other tables within a given sqlite3 database with the same fullpkgpath field, without having to manually specify any such extra tables?

    • If the answer to be above is, "no", then how would I manually specify which other tables I want the statement applied to? Consider that only the categories table has the categories that could be directly compared with names of packages (to be fair, the ports table also has a categories field, but it has all the categories of a given port jammed into one field (space separated), as opposed to separate table entries as is the case in the categories table).

来源:https://stackoverflow.com/questions/21195043/sql-update-a-given-field-in-all-tables-instead-of-just-one-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!