Hi I have a development built on MYSQL and considering on moving to PostGres due to the license costs for commercial software.
In my MYSQL I have multiple tables where I rely on the use of the UUID_SHORT() function as primary key in these tables. See link: Mysql UUID_SHORT Info
Does PostGres have a similar function to UUID_SHORT function? I am looking for a uniqiue ID and not interested in a sequence. Also something based on the system time like the UUID_SHORT would be awesome. Also below is the class function I use in PHP when I want to get a unique ID for primary key insert in MYSQL.
Appreciate any comments as this would be the main reason to or not transfer to PostGres.
function getUniqueId(){
//return unique id
$temp_id = strval(uniqid());
$temp = $this->conn->prepare('CREATE TEMPORARY TABLE tempId (temp_id VARCHAR(30) PRIMARY KEY, id BIGINT UNSIGNED)');
$temp->execute();
$temp = $this->conn->prepare('INSERT INTO tempId(temp_id, id) VALUES(:temp_id, UUID_SHORT())');
$temp->bindParam(':temp_id', $temp_id, PDO::PARAM_STR);
$temp->execute();
$temp = $this->conn->prepare('SELECT id FROM tempId WHERE temp_id = :temp_id ');
$temp->bindParam(':temp_id', $temp_id, PDO::PARAM_STR);
$temp->execute();
$tempResult= $temp->fetchAll(PDO::FETCH_ASSOC);
$temp = $this->conn->prepare('DROP TEMPORARY TABLE tempId');
$temp->execute();
$temp_id = $tempResult[0]['id'];
return $temp_id;
}