– pgsql
– Install function
– UUID generation function: pgsql default installation does not have this type of function. If an error occurs when the script is executed here, you need to open the following comments and install the UUID generation function
create extension “uuid-ossp” ;
– Using functions
select uuid_generate_v4(); select replace(cast(uuid_generate_v4() as VARCHAR), ‘-', ‘'); select translate(cast(uuid_generate_v4() as VARCHAR), ‘-', ‘'); INSERT INTO mdc.base_org ( uuid, NAME, org_parent_uuid, delete_flag, court_uuid, create_time, update_time, create_user, update_user, is_parent, sort_by, org_type ) VALUES ( ( SELECT REPLACE ( CAST ( uuid_generate_v4 () AS VARCHAR ), ‘-', ‘' ) ), ‘Testing community', ‘0', 1, ‘c69aeede4f6341929721e2892beec3cb', now(), now(), ‘admin', ‘admin', TRUE, ‘001', ‘1' );
Supplement: Solve the problem of failing to create uuid function in postgressql
ERROR: could not access file "$libdir/uuid-ossp"
<span style="font-family:Microsoft YaHei;">STATEMENT: CREATE FUNCTION uuid_generate_v4() RETURNS uuid LANGUAGE c STRICT AS '$libdir/uuid-ossp', 'uuid_generate_v4';</span>
Solution:
There is no file under the lib/postgresql directory.
I put this file into the lib directory from other installed databases I already have;
or
<span style="font-size:14px;">apt-get install postgresql-contrib </span>
Then execute the psql command to install uuid-ossp, and the execution is successful
The above is personal experience. I hope you can give you a reference and I hope you can support me more. If there are any mistakes or no complete considerations, I would like to give you advice.