This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT DISTINCT n.nspname AS schemaname | |
,c.relname AS tablename | |
,a.attname AS COLUMN | |
,a.attnum AS column_position | |
,pg_catalog.format_type(a.atttypid, a.atttypmod) AS TYPE | |
,pg_catalog.format_encoding(a.attencodingtype) AS encoding | |
,a.attisdistkey AS distkey | |
,a.attsortkeyord AS sortkey | |
,a.attnotnull AS notnull | |
,a.attencodingtype AS compression |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH COLUMN_DEFINITION AS ( | |
SELECT | |
TABLE_NAME, | |
COLUMN_NAME, | |
CASE | |
WHEN (DATA_TYPE= 'NUMBER' AND DATA_SCALE = 0 AND DATA_PRECISION <= 9) THEN 'INTEGER' | |
WHEN (DATA_TYPE= 'NUMBER' AND DATA_SCALE = 0 AND DATA_PRECISION <= 18) THEN 'BIGINT' | |
WHEN (DATA_TYPE= 'NUMBER' AND DATA_SCALE = 0 AND DATA_PRECISION >= 19) THEN 'DECIMAL(' || DATA_PRECISION || ',0)' | |
WHEN (DATA_TYPE= 'NUMBER' AND DATA_SCALE > 0) THEN 'DECIMAL(' || DATA_PRECISION || ',' || DATA_SCALE ||')' | |
WHEN (DATA_TYPE= 'NUMBER' AND nvl(DATA_SCALE,0) = 0 AND nvl(DATA_PRECISION,0) = 0) THEN 'DECIMAL(38,18)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package testjava; | |
import java.util.HashMap; | |
import java.util.Random; | |
/* | |
* URL Shortener | |
*/ | |
public class URLShortener { | |
// storage for generated keys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT /* + RULE */ | |
df.tablespace_name AS "Tablespace" | |
,df.bytes / (1024 * 1024 * 1024) AS "Size (GB)" | |
,Trunc(fs.bytes / (1024 * 1024 * 1024)) AS "Free (GB)" | |
FROM ( | |
SELECT tablespace_name | |
,Sum(bytes) AS bytes | |
FROM dba_free_space | |
GROUP BY tablespace_name | |
) fs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT OBJECT_TYPE | |
,OBJECT_SCHEMA | |
,OBJECT_NAME | |
FROM ( | |
SELECT 'TABLE' AS OBJECT_TYPE | |
,TABLE_NAME AS OBJECT_NAME | |
,TABLE_SCHEMA AS OBJECT_SCHEMA | |
FROM information_schema.TABLES | |
UNION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import pg8000 as dbapi | |
from pprint import pprint | |
def getconnection(database,host,port,user,password): | |
conn= None | |
try: | |
conn=dbapi.connect(database=database,host=host, port=port,\ | |
user=user,password=password,ssl=True) | |
except Exception as err: |