Friday 31 July 2020

How To Load Database In PostgreSQL Using CMD Command Prompt Or PSQL Comm...



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.


pg_restore -U postgres -d dvdrental D:\dvdrental.tar
psql -U postgres postgres < D:\dvdrental.sql


The Purpose is to load database using CMD in PostgreSQL, 2 ways to do it.

How To Convert Table Records Into JSON Array In PostgreSQL | row_to_json...




Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.





-- Purpose is to convert table records into JSON (JavaScript Object Notation)





--row_to_json()



select * from actor;



select row_to_json(row(actor_id,first_name)) from actor;





select row_to_json(actor_alias)

from (select actor_id,first_name from actor) actor_alias;





select row_to_json(actor) from actor;





explain

select array_to_json(array_agg(row_to_json(actor_alias)))

from (select * from actor) actor_alias;




Thursday 16 July 2020

How To Pass Array As Parameter Into A Stored Function/Procedure In Postg...



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



CREATE TABLE public.testing

(

my_values numeric

);







CREATE OR REPLACE FUNCTION public.test_func(p_values numeric[])

RETURNS text

LANGUAGE 'plpgsql'



COST 100

VOLATILE

AS $BODY$

declare

v_array_length numeric(10,0) := 0;

v_msg character varying(100) := null;

begin

v_array_length := array_length(p_values,1);



if (v_array_length > 0) then

for i in 1..v_array_length loop

insert into public.testing (my_values) values (p_values[i]);

end loop;



v_msg := 'Array Processed Successfully With Length'||v_array_length;

else



v_msg := 'Array having no values';

end if;



return v_msg;



end;

$BODY$;







SELECT public.test_func('{123,34}'::numeric[]);  -- 1





SELECT public.test_func('{123,34}');  -- 2







SELECT public.test_func('{}');  -- 3







select * from public.testing;

How To Take Backup Of Database As SQL/TAR File And How Restore Database ...



Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.



In this video, I have explained How To Take Backup Of Database As SQL/TAR File And How Restore Database In PostgreSQL Using pgAdmin4.
This is a very helpful video if you are a developer working with PostgreSQL.

Wednesday 15 July 2020

How To Export Table Data Into A CSV File And Import Data From CSV File I...




Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.





The purpose is to Export table data into a CSV (comma-separated values) file and import data from a CSV file into a table in PostgreSQL using pgAdmin.