Create a database:
Create database <database name>
Create a schema:
Create schema <schema name>
Rename a schema:
ALTER SCHEMAname
RENAME TOnew_name
To show the current search path:
SHOW search_path;
Put a schema in the path:
SET search_path TO myschema;
Put multiple schemas:
SET search_path TO myschema, public;
Create a
Auto incremental P
rimary Key:
create table test(
id serial primary key
);
Create a table with foreign key:
create table table_A(
field_1,
contraint fk_name foreign key (field_1) references table_B (field_1)
);
Rename a table in postgres:
ALTER TABLE "NambreDeTablaActual" RENAME TO "NuevoNombreTabla";
String to timestamp:
SELECT TO_TIMESTAMP('2023-05-02 00:20:25','YYYY-MM-DD HH24:MI:SS');
No hay comentarios:
Publicar un comentario