Тёмный

How to Use a Custom Template Database in PostgreSQL 

PG Casts by Hashrocket
Подписаться 1,7 тыс.
Просмотров 1,9 тыс.
50% 1

This PG Casts episode is sponsored by Hashrocket, a consultancy specializing in PostgreSQL; learn more at hashrocket.com. To see more PG Casts videos, visit our RU-vid channel or www.pgcasts.com
Transcript:
Hey everyone, today we're going to look at how to create and use a custom template database in Postgres.
To create a new template database, we use the normal "create database" command, passing the parameter "is_template" with a value of "true".
If we are customizing locales or encoding on our new custom template, we should make sure that we are cloning from Postgres's `template0`, rather than the default `template1`.
```sql
create database example is_template true encoding 'SQL_ASCII' template template0;
```
We can see our new template database with the list command.
```
\l
```
And we can verify that it is a template by checking out the pg_database data.
```sql
select datistemplate from pg_database where datname = 'example';
```
To create a new database cloned from our custom template, we use the "create database" command, passing our template name to the template parameter.
```sql
create database test template example;
```
Using the list metacommand again, we can see that our new database has the SQL_ASCII encoding from our custom template.
```
\l
```
Thanks for watching!

Опубликовано:

 

18 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии    
Далее
PostgresOpen 2019 Advanced Data Types In PostgreSQL
48:46
Finding and Killing Connections in Postgres
5:09
Просмотров 5 тыс.
Postgres Conditionals: How to Use Case
3:22
Просмотров 6 тыс.
Elon Musk fires employees in twitter meeting DUB
1:58
Create Table inside SQL Developer
10:58
Просмотров 28 тыс.
PostgreSQL default and Template databases
14:32
Просмотров 3,2 тыс.
PostgreSQL in 100 Seconds
2:37
Просмотров 731 тыс.