Anasayfa / Postgresql

Postgresql

Postgresql 13 random tckn generator

Öncelikle plpython3 ‘ü yüklüyoruz sudo apt-get install postgresql-contrib postgresql-plpython3-13 CREATE OR REPLACE FUNCTION random_tckn () RETURNS TEXT AS $$ from random import randint tcno = str(randint(100000000, 1000000000)) list_tc = list(map(int, tcno)) tc10 = (sum(list_tc[::2]) * 7 - sum(list_tc[1::2])) % 10 new_tc = tcno + str(tc10) + str((sum(list_tc[:9]) + tc10) % …

Devamını Oku »

ubuntu server 20.04 install postgresql and remote access

sudo apt-get update sudo apt-get upgrade sudo reboot sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt-get update sudo apt-get -y install postgresql   dikkat aşağıdaki işlem veritabanı sunucunuzu tamamen dışarıya açar bilinçli bir şekilde yaptığınızdan …

Devamını Oku »

postgresql find dependent object

https://stackoverflow.com/questions/4462908/find-dependent-objects-for-a-table-or-view   SELECT dependent_ns.nspname as dependent_schema , dependent_view.relname as dependent_view , source_ns.nspname as source_schema , source_table.relname as source_table , pg_attribute.attname as column_name FROM pg_depend JOIN pg_rewrite ON pg_depend.objid = pg_rewrite.oid JOIN pg_class as dependent_view ON pg_rewrite.ev_class = dependent_view.oid JOIN pg_class as source_table ON pg_depend.refobjid = source_table.oid JOIN pg_attribute ON pg_depend.refobjid …

Devamını Oku »

postgresql gtip noktalı çevir

create or replace function fn_getGtipNoktali(p_gtip varchar) returns varchar language plpgsql as $$ declare temp_gtip varchar; ret_gtip varchar; begin SELECT replace(p_gtip, '.', '') into temp_gtip; select SUBSTRING ( temp_gtip ,0 , 5 )||'.'||SUBSTRING ( temp_gtip ,5 , 2 )||'.'||SUBSTRING ( temp_gtip ,7 , 2 )||'.'||SUBSTRING ( temp_gtip ,9 , 2 )||'.'||SUBSTRING …

Devamını Oku »