Share via

Would "az postgres db create" overwirte existing db with the same name?

Ken Yuan 21 Reputation points
2022-06-29T02:30:04.3+00:00

Example:
An postgres database with an existing database called test.
After running "az postgres db create" and creating a new data base called test, would this overwrite the old test database?
If not what would happen in the background? Just want to understand this more, it appears to be not much logging/warning too after the command is completed but initial test is that it will not overwrite.

Thanks,
Ken

Azure Database for PostgreSQL
0 comments No comments

Answer accepted by question author

Anurag Sharma 17,636 Reputation points
2022-06-29T08:57:54.08+00:00

Hi @Ken Yuan , welcome to Microsoft Q&A forum.

As I understand, you want to know if this command is going to overwrite the existing database or not.

So this command first checks if the mentioned database name exists on the Azure PostgreSQL Server or not. Behind the scenes it used rest API 'PUT' command. If it is not present, it creates a new database, however if the database exists then it does not overwrite it but returns the basic configuration of database.

You can append '--debug' to the command to see the verbose logging as well.

az postgres db create -g <resource group> -s <server name> -n <database name> --debug  

Please let me know if any more details needed.

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.