Skip to content

Instantly share code, notes, and snippets.

View unmaykr-aftermath's full-sized avatar

UnMaykr unmaykr-aftermath

  • Nomad
View GitHub Profile
@seahrh
seahrh / pg_disk_usage.sql
Created October 25, 2018 10:38
postgres queries to check disk usage
-- pg equivalent of DESCRIBE TABLE
select column_name, data_type, character_maximum_length
from INFORMATION_SCHEMA.COLUMNS where table_name = 'my_table_name';
-- General Table Size Information, Performance Snippets
-- Disk usage, Works with PostgreSQL>=9.2
-- This will report size information for all tables, in both raw bytes and "pretty" form.
SELECT *, pg_size_pretty(total_bytes) AS total
@0xjac
0xjac / private_fork.md
Last active May 29, 2025 19:28
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare [email protected]:usi-systems/easytrace.git

@scaryguy
scaryguy / change_primary_key.md
Last active February 4, 2025 02:09
How to change PRIMARY KEY of an existing PostgreSQL table?
-- Firstly, remove PRIMARY KEY attribute of former PRIMARY KEY
ALTER TABLE <table_name> DROP CONSTRAINT <table_name>_pkey;
-- Then change column name of  your PRIMARY KEY and PRIMARY KEY candidates properly.
ALTER TABLE <table_name> RENAME COLUMN <primary_key_candidate> TO id;