5 ms·
Curious as to why not simply use UUIDs instead? Its extremely easy to use uuids as the primary key; make the column a `uuid` type and the `uuid-ossp` extension
by aartav 6y ago
Curious as to why not simply use UUIDs instead?
Its extremely easy to use uuids as the primary key; make the column a `uuid` type and the `uuid-ossp` extension will generate them. Your sql would look like:
CREATE TABLE posts (
post_id uuid DEFAULT uuid_generate_v4(),
PRIMARY_KEY(post_id)
);
- muminoff 6y agoIf you use Postgresql 13 version you don't need to install `uuid-ossp` extension. There's already built-in function to generate UUID which is `gen_random_uuid ()`.
- maxcan 6y agoI'd guess the idea would be to have more succinct URLs. As to whether or not primary keys should even ever be exposed in URLs, different story.