Install PostgreSQL postgres



---Add the PostgreSQL repository.

yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

---Install PostgreSQL.

yum install -y postgresql13-server

---Initialize the database.

/usr/pgsql-13/bin/postgresql-13-setup initdb

---Enable and start the service.

systemctl enable --now postgresql-13


---psql shell.

-iu postgres psql

-Create a database named test.

 CREATE DATABASE test;

-Connect to the new database named test.

\c test

- Create a table named messages.

CREATE TABLE messages (handle VARCHAR(32), message VARCHAR(280));

-Insert a couple rows into the new table named messages.

INSERT INTO messages VALUES ('User', 'This is a test message.');

INSERT INTO messages VALUES ('User', 'This is another test message.');

-Query all rows from the table named messages.

SELECT * FROM messages;


签名:这个人很懒,什么也没有留下!
最新回复 (0)
返回