sql - split table after values of specific row -


postgres table 'mytable' has columns 'a','b','c' , 'mycol'.

how can split table efficiently, entries having value 'x' in 'mycol' in 1 table ('mytablex'), value 'y' in ('mytabley')and value 'z' ('mytablez') in another.

can done in pure sql?

in postgres, can do:

create table mytablex     select * mytable mycol = 'x'; 

you repeat each table.

having said that, there few reasons why want this. splitting table unlikely make queries more efficient; increases number of tables; new tables can out-of-date larger tables; , on.

i can think of 1 reason. provide separate access controls each table. in case, there other options, splitting data separate tables can simplify security.

if need this, views better approach separate tables:

create view mytablex     select * mytable mycol = 'x'; 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -