4
如何有条件地停止psql脚本(基于变量值)?
让我们考虑以下示例(从psql脚本开始): \c :db_to_run_on TRUNCATE the_most_important_table; -- tried to avoid similarities to anything that exists out there 现在,如果通过命令运行它 psql [connection details] -v db_to_run_on=\'dev_database\' 然后它就运行了,用户很高兴。但是,如果他决定指定-v db_to_run_on=production_database呢?(让我们假设这会发生,就像人们rm -rf / # don't try this at home!!!偶尔运行一样。)希望该表有一个新的备份... 因此出现了一个问题:如何检查传递给脚本的变量并根据其值停止进一步处理?
10
postgresql
psql