PostgreSQL

PgSQL: View Rows Per Table

Posted on

Two Methods: First: SELECT schemaname,relname,n_live_tup FROM pg_stat_user_tables ORDER BY n_live_tup DESC;   Second: SELECT nspname AS schemaname,relname,reltuples FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) WHERE nspname NOT IN (‘pg_catalog’, ‘information_schema’) AND relkind=’r’ ORDER BY reltuples DESC;

MySQL

MySQL: Script to Create a Calendar

Posted on

Copied and tweaked from Github https://gist.github.com/bryhal/4129042 DROP TABLE IF EXISTS time_dimension; CREATE TABLE time_dimension ( id INTEGER PRIMARY KEY, — year*10000+month*100+day db_date DATE NOT NULL, year INTEGER NOT NULL, month INTEGER NOT NULL, — 1 to 12 day INTEGER NOT NULL, — 1 to 31 quarter INTEGER NOT NULL, — 1 to 4 week INTEGER […]

MySQL

MySQL: Replace Accented Characters

Posted on

UPDATE leads_cstm SET linkedin_name_c = REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(linkedin_name_c,’ù’,’u’),’ú’,’u’),’û’,’u’),’ü’,’u’),’ý’,’y’),’ë’,’e’),’à’,’a’),’á’,’a’),’â’,’a’),’ã’,’a’),’ä’,’a’),’å’,’a’),’æ’,’a’),’ç’,’c’),’è’,’e’),’é’,’e’),’ê’,’e’),’ë’,’e’),’ì’,’i’),’í’,’i’),’î’,’i’),’ï’,’i’),’ð’,’o’),’ñ’,’n’),’ò’,’o’),’ó’,’o’),’ô’,’o’),’õ’,’o’),’ö’,’o’),’ø’,’o’);