Тёмный
No video :(

Part 11 - Postgres: What is Schema in PostgreSQL  

E-MultiSkills Database  services
Подписаться 8 тыс.
Просмотров 26 тыс.
50% 1

What is Schema in postgresql
A PostgreSQL database cluster contains one or more named databases.
A database contains one or more named schemas.
Schema contains tables, data types, functions, and operators etc.
2/many schemas in one database
schema1 : Create a table actor;
schema2 : Create a table actor;
User can access actor which is present in schema1 and schema2 with same name.
Schemas are analogous to directories at the operating system level.
How to create a schema
CREATE SCHEMA schema1;
To create or access objects in a schema, write a qualified name consisting of the schema name and table name separated by a dot:
database.schema.table
select * from actor;.
CREATE TABLE schema1.actor
(
actor_id integer NOT NULL DEFAULT nextval('actor_actor_id_seq'::regclass),
first_name character varying(45) COLLATE pg_catalog."default" NOT NULL,
last_name character varying(45) COLLATE pg_catalog."default" NOT NULL,
last_update timestamp without time zone NOT NULL DEFAULT now(),
CONSTRAINT actor_pkey PRIMARY KEY (actor_id)
)
select * from schema1.actor;
select * from schema2.actor;
select * from actor;
To drop a schema if it's empty (all objects in it have been dropped), use.
DROP SCHEMA schema1;
DROP SCHEMA schema1 CASCADE;
The Schema Search Path
postgres=# SHOW search_path;
search_path
-----------------
"$user", public
(1 row)
Schema with the same name as the current user is to be searched.
To put our new schema in the path, we use:
postgres# \c dvdrental;
postgres# show search_path;
postgres# SET search_path TO schema1,public;
Note : Then we no longer have access to the public schema without explicit qualification.
There is nothing special about the public schema except that it exists by default
Schemas and Privileges
By default, users cannot access any objects in schemas they do not own.
by default, everyone has CREATE and USAGE privileges on the schema public.
This allows all users that are able to connect to a given database to create objects in its public.
Usage Patterns
1) issue REVOKE CREATE ON SCHEMA public FROM PUBLIC. create a schema for each user with the same name as that user.
2)Remove the public schema from the default search path by issuing ALTER ROLE ALL SET search_path = "$user".
3)Keep the default.
Conclusion :
you should not use the public schema.

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

 

25 авг 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 22   
@pranavkutty5736
@pranavkutty5736 2 года назад
Very informative video, Thanks!
@jonnytheponny5753
@jonnytheponny5753 4 года назад
thanks, very good information!
@EMultiSkillsDatabaseServices
@EMultiSkillsDatabaseServices 4 года назад
Glad it was helpful!
@somanyVideo
@somanyVideo 3 года назад
postgres schema에대해서 유일하게 있는 동영상이다. thank. 자막 번역 감사합니다.
@EMultiSkillsDatabaseServices
@EMultiSkillsDatabaseServices 3 года назад
Thank you for finding it useful .
@techocean6372
@techocean6372 2 года назад
nice content
@fatemehmohseni-
@fatemehmohseni- 11 месяцев назад
very nice thank you
@sabanaar
@sabanaar 3 года назад
Thanks, very useful introduction to PostgreSQL!!!
@EMultiSkillsDatabaseServices
@EMultiSkillsDatabaseServices 3 года назад
Happy to share , more info on way... Thanks for finding it useful.
@Winit18
@Winit18 3 года назад
Whoa very nice content ..loved it..nobody explained like you do 😃
@EMultiSkillsDatabaseServices
@EMultiSkillsDatabaseServices 3 года назад
Glad you liked it
@parabola689
@parabola689 3 года назад
very useful thank you! :)
@EMultiSkillsDatabaseServices
@EMultiSkillsDatabaseServices 3 года назад
You're welcome!
@inclinedscorpio
@inclinedscorpio 2 года назад
Hi! Thanks! I have a doubt. I created role with CRUD privileges and a new user and assigned role to the user. How can I revoke the modify table privileges? I don't want the user to run Alter or Drop commands. Only CRUD operations must be used. Any idea? :)
@utubetanki
@utubetanki 3 года назад
Good information. Could you advise order of videos in which we can lookup for a Beginner please?
@EMultiSkillsDatabaseServices
@EMultiSkillsDatabaseServices 3 года назад
Thank you ,I will combine all in a single video in the series the way it should be. Thank for notifying me about that .
@EMultiSkillsDatabaseServices
@EMultiSkillsDatabaseServices 3 года назад
That's been arranged
@tamask
@tamask Год назад
Ok, but why should I use schemas? If I want to create two tables with the same table name, why not just create two separate databases? Same if I want to control user access… Why not just create two databases? **What are the use-cases where I actually have to use schemas and using two separate databases does not solve the problem?**
@EMultiSkillsDatabaseServices
Create a particular user objects with in a names space and avoid using public schema accessible to all
@EMultiSkillsDatabaseServices
There is no relationship when you planned to use separate databases , regardless of that you should never create your objects in public schema. Why would you want all users to view your sensetive data ? If you donot want security go for that .
@tamask
@tamask Год назад
@@EMultiSkillsDatabaseServices Ok, thanks. It wasn't clear to me that setting permissions on the database itself wouldn't prevent other users from reading it. I didn't know that preventing read access of other users is possible only by the use of schemas.
@jiechaowang983
@jiechaowang983 Год назад
@@EMultiSkillsDatabaseServices Can you give a real world example where we want user1 to only have access to user1 schema and user2 to only have access to user2 schema?
Далее
PostgreSQL roles, schema and security
32:32
Просмотров 18 тыс.
Part 15 : PostgreSQL : What is Vacuum and autovacuum.
17:46
Wife habit 😂 #shorts
00:16
Просмотров 49 млн
Only I get to bully my sister 😤
00:27
Просмотров 15 млн
Part 13- PostgreSQL user and role Management
22:53
Просмотров 53 тыс.
Postgres Internal Architecture Explained
33:16
Просмотров 150 тыс.
Part 21 - PostgreSQL : What is a Pg_base backup.
24:36
Part  17-  PostgreSQL Routine maintenance tasks.
9:32
Tuning PostgreSQL for High Write Workloads
42:33
Просмотров 50 тыс.
PostgreSQL In-Depth Training: Fundamentals Part 1
52:55
Wife habit 😂 #shorts
00:16
Просмотров 49 млн