Closed derkan closed 3 years ago
Hi, To set DEFAULT value for an PK of table, I wonder if has anyone tried to generate a valid ksuid value by using SQL.
DEFAULT
PK
ksuid
For example for UUIDv4, we can generate default value if uuid-ossp extension is not installed for PostrgreSQL as:
uuid-ossp
`CREATE TABLE IF NOT EXISTS table ( id VARCHAR(36) DEFAULT md5(random()::text || clock_timestamp()::text)::uuid NOT NULL, ....
Of course it'll be better to generate from application but, I it makes simpler to add default value for manual interactions with tables.
Has anyone tried to develop an SQL function to geneate ksuid?
It's certainly possible, here's what I have done https://github.com/daleobrien/sql-ksuid
thank you, now the missing part is found! 👏
Hi, To set
DEFAULT
value for anPK
of table, I wonder if has anyone tried to generate a validksuid
value by using SQL.For example for UUIDv4, we can generate default value if
uuid-ossp
extension is not installed for PostrgreSQL as:Of course it'll be better to generate from application but, I it makes simpler to add default value for manual interactions with tables.
Has anyone tried to develop an SQL function to geneate
ksuid
?