Database connectivity:
-bash-4.2$ psql
psql (9.2.24, server 12.5)
WARNING: psql version 9.2, server version 12.0.
Some psql features might not work.
Type "help" for help.
postgres=#
check the version
postgres=# show server_version;
server_version
----------------
12.5
(1 row)
Database creation:
-----------------
-----------------
postgres=# create database mysql4;
CREATE DATABASE
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
mysql4 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
To know the connection details:
--------------------------------
postgres-# \c
psql (9.2.24, server 12.5)
WARNING: psql version 9.2, server version 12.0.
Some psql features might not work.
You are now connected to database "postgres" as user "postgres".
postgres-#
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
mysql4 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
connect to database:
postgres=# \c mysql4
psql (9.2.24, server 12.5)
WARNING: psql version 9.2, server version 12.0.
Some psql features might not work.
You are now connected to database "mysql4" as user "postgres".
--create a schema
mysql4=# create schema myschema;
CREATE SCHEMA
create a table inside the schema
--
mysql4=# create table myschema.table20( int integer, password char(10));
CREATE TABLE
select the tables
^
mysql4=# select * from pg_catalog.pg_tables;
schemaname | tablename | tableowner | tablespace | hasindexes | hasrules | hastriggers | rowsecurity
--------------------+-------------------------+------------+------------+------------+----------+-------------+-------------
myschema | table20 | postgres | | f | f | f | f
pg_catalog | pg_statistic | postgres | | t | f | f | f
pg_catalog | pg_type | postgres | | t | f | f | f
pg_catalog | pg_foreign_server | postgres | | t | f | f | f
pg_catalog | pg_authid | postgres | pg_global | t
or
mysql4=# select * from pg_catalog.pg_tables where schemaname !='information_schema' and schemaname !='pg_catalog';
schemaname | tablename | tableowner | tablespace | hasindexes | hasrules | hastriggers | rowsecurity
------------+-----------+------------+------------+------------+----------+-------------+-------------
myschema | table20 | postgres | | f | f | f | f
(1 row)
mysql4=#
mysql4=# insert into myschema.table20 values(1,'hi');
INSERT 0 1
mysql4=# insert into myschema.table20 values(2,'howru');
INSERT 0 1
mysql4=# select * from myschema.table20;
int | password
-----+------------
1 | hi
2 | howru
(2 rows)
No comments:
Post a Comment