官术网_书友最值得收藏!

Managing Odoo databases

We've seen how to create and initialize new Odoo databases from the command line. There are more commands worth knowing about for managing databases.

Although the Odoo server automatically takes care of that, we can manually create PostgreSQL databases from the command line, using:

$ createdb MyDB

More interesting, it can also create a new database by copying an existing one, using the --template option. For this to work, the copied database can't have open connections to it, so make sure your Odoo instance is stopped and there is no other connection open for it. The command to use looks like this:

$ createdb --template=MyDB MyDB2

In fact, every time we create a database, a template is used. If none is specified, a predefined one called template1 is used.

To list the existing databases in your system, use the PostgreSQL psql utility with the -l option:

$ psql -l

Running it will list the two databases we have created so far: MyDB and MyDB2. The list will also display the encoding used in each database. The default is UTF-8, which is the encoding needed for Odoo databases.

To remove a database you no longer need (or want to recreate), use the dropdb command:

$ dropdb MyDB2

Now you know the basics to work with databases. To learn more about PostgreSQL, refer to the official documentation at http://www.postgresql.org/docs/.

WARNING: The drop database command will irrevocably destroy your data. Be careful when using it and always keep backups of important databases before using this command.
主站蜘蛛池模板: 吴旗县| 佛冈县| 桂阳县| 微博| 嘉鱼县| 九江市| 巴彦淖尔市| 泾川县| 延寿县| 楚雄市| 清河县| 三明市| 东莞市| 塘沽区| 永修县| 南宫市| 伊金霍洛旗| 武胜县| 上林县| 应城市| 海丰县| 垣曲县| 徐州市| 上杭县| 镇远县| 易门县| 大新县| 措勤县| 长寿区| 顺昌县| 台南县| 梓潼县| 望江县| 车险| 都匀市| 广昌县| 巴彦淖尔市| 衡阳县| 大石桥市| 库车县| 喜德县|