Skip to content

Commit

Permalink
Pg 798 restructure 14 (#605)
Browse files Browse the repository at this point in the history
* Restructured docs
* Reworked the What's in it section
* Added power number
* Added icons
  • Loading branch information
nastena1606 authored Jun 19, 2024
1 parent def7800 commit 18dab7e
Show file tree
Hide file tree
Showing 47 changed files with 630 additions and 304 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"Quickstart"
]
}
47 changes: 35 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,39 @@

Thank you for deciding to contribute and help us improve Percona Distribution for PostgreSQL documentation!

We welcome contributors from all users and community. By contributing, you agree to the [Percona Community code of conduct](https://github.com/percona/community/blob/main/content/contribute/coc.md).
We welcome contributors from all users and community. By contributing, you agree to the [Percona Community code of conduct :octicons-link-external-16: :octicons-link-external-16:](httpss://github.com/percona/community/blob/main/content/contribute/coc.md).

<<<<<<< HEAD
This repository contains the source file for `pg_stat_monitor` documentation and this document explains how you can contribute to it.
=======
You can contribute to documentation in the following ways:

1. **Request a doc change through a Jira issue**. If you’ve spotted a doc issue (a typo, broken links, inaccurate instructions, etc.) but don’t have time nor desire to fix it yourself - let us know about it.

- Click the **Submit DOC bug** link on the sidebar. This opens the [Jira issue tracker :octicons-link-external-16: :octicons-link-external-16:](httpss://jira.percona.com/projects/DISTPG/issues) for the doc project.
- Sign in (create a Jira account if you don’t have one) and click **Create** to create an issue.
- Describe the issue you have detected in the Summary, Description, Steps To Reproduce, Affects Version fields.

2. **[Contribute to documentation yourself](#contribute-to-documentation-yourself)**. There is the **Edit this page** link that leads you to the source file of the page on GitHub. There you make changes, create a pull request that we review and add to the doc project. For details how to do it, read on.
>>>>>>> 9ee26788... Restructured docs
## Contribute to documentation

Percona Distribution for PostgreSQL documentation is written in [Markdown](https://www.markdownguide.org/basic-syntax/) language, so you can
Percona Distribution for PostgreSQL documentation is written in [Markdown :octicons-link-external-16:](httpss://www.markdownguide.org/basic-syntax/) language, so you can
[edit it online via GitHub](#edit-documentation-online-vi-github). If you wish to have more control over the doc process, jump to how to [edit documentation locally](#edit-documentation-locally).

To contribute to the documentation, you should be familiar with the following technologies:

- [MkDocs](https://www.mkdocs.org/getting-started/) documentation generator. We use it to convert source ``.md`` files to .html and PDF documents.
- [git](https://git-scm.com/) and [GitHub](https://guides.github.com/activities/hello-world/)
- [Docker](https://docs.docker.com/get-docker/). It allows you to run MkDocs in a virtual environment instead of installing it and its dependencies on your machine.
<<<<<<< HEAD

- [MkDocs :octicons-link-external-16:](httpss://www.mkdocs.org/getting-started/) documentation generator. We use it to convert source ``.md`` files to .html and PDF documents.
- [git :octicons-link-external-16:](httpss://git-scm.com/) and [GitHub :octicons-link-external-16:](httpss://guides.github.com/activities/hello-world/)
- [Docker :octicons-link-external-16:](httpss://docs.docker.com/get-docker/). It allows you to run MkDocs in a virtual environment instead of installing it and its dependencies on your machine.
=======
- [Markdown :octicons-link-external-16: :octicons-link-external-16:](httpss://www.markdownguide.org/basic-syntax/) markup language. It is used to write the documentation.
- [MkDocs :octicons-link-external-16: :octicons-link-external-16:](httpss://www.mkdocs.org/getting-started/) documentation generator. We use it to convert source ``.md`` files to html and PDF documents.
- [git :octicons-link-external-16: :octicons-link-external-16:](httpss://git-scm.com/) and [GitHub :octicons-link-external-16: :octicons-link-external-16:](httpss://guides.github.com/activities/hello-world/)
- [Docker :octicons-link-external-16: :octicons-link-external-16:](httpss://docs.docker.com/get-docker/). It allows you to run MkDocs in a virtual environment instead of installing it and its dependencies on your machine.
>>>>>>> 9ee26788... Restructured docs
There are several active versions of the documentation. Each version derives from the major version of PostgreSQL, included in the distribution.

Expand All @@ -32,7 +51,11 @@ The source .md files are in the ``docs`` directory.

### Edit documentation online via GitHub

1. Click the **Edit this page** icon next to the page title. The Markdown file of the page opens in GitHub editor in your browser. If you haven’t worked with the repository before, GitHub creates a [fork](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo) of it for you.
<<<<<<< HEAD
1. Click the **Edit this page** icon next to the page title. The Markdown file of the page opens in GitHub editor in your browser. If you haven’t worked with the repository before, GitHub creates a [fork :octicons-link-external-16:](httpss://docs.github.com/en/github/getting-started-with-github/fork-a-repo) of it for you.
=======
1. Click the **Edit this page** link on the sidebar. The Markdown file of the page opens in GitHub editor in your browser. If you haven’t worked with the repository before, GitHub creates a [fork :octicons-link-external-16: :octicons-link-external-16:](httpss://docs.github.com/en/github/getting-started-with-github/fork-a-repo) of it for you.
>>>>>>> 9ee26788... Restructured docs
2. Edit the page. You can check your changes on the **Preview** tab.

Expand Down Expand Up @@ -95,8 +118,8 @@ Learn more about the documentation structure in the [Repository structure](#repo

#### Use Docker

1. [Get Docker](https://docs.docker.com/get-docker/)
2. We use [this Docker image](https://github.com/Percona-Lab/percona-doc-docker) to build documentation. Run the following command:
1. [Get Docker :octicons-link-external-16: :octicons-link-external-16:](httpss://docs.docker.com/get-docker/)
2. We use [this Docker image :octicons-link-external-16: :octicons-link-external-16:](httpss://github.com/Percona-Lab/percona-doc-docker) to build documentation. Run the following command:

```sh
docker run --rm -v $(pwd):/docs perconalab/pmm-doc-md mkdocs build
Expand All @@ -121,8 +144,8 @@ The PDF document is in the ``site/pdf`` folder.

#### Install MkDocs and build locally

1. Install [pip](https://pip.pypa.io/en/stable/installing/)
2. Install [MkDocs](https://www.mkdocs.org/getting-started/#installation).
1. Install [pip :octicons-link-external-16: :octicons-link-external-16:](httpss://pip.pypa.io/en/stable/installing/)
2. Install [MkDocs :octicons-link-external-16: :octicons-link-external-16:](httpss://www.mkdocs.org/getting-started/#installation).
3. While in the root directory of the doc project, run the following command to build the documentation:

```sh
Expand All @@ -136,7 +159,7 @@ mkdocs serve
```

6. To build the PDF documentation, do the following:
- Install [mkdocs-with-pdf plugin](https://pypi.org/project/mkdocs-with-pdf/)
- Install [mkdocs-with-pdf plugin :octicons-link-external-16: :octicons-link-external-16:](httpss://pypi.org/project/mkdocs-with-pdf/)
- Run the following command

```sh
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ Welcome to Percona Distribution for PostgreSQL documentation!

Percona Distribution for PostgreSQL is a collection of tools to assist you in managing your PostgreSQL database system. It includes the upstream version of PostgreSQL and a selection of extensions that enable solving essential practical tasks efficiently.

This repository contains the source files for [Percona Distribution for PostgreSQL documentation](https://www.percona.com/doc/postgresql/13/index.html). The documentation is written in [reStructured text markup language](https://docutils.sourceforge.io/rst.html) and is created using [Sphinx Python Documentation Generator](https://www.sphinx-doc.org/en/master/).
This repository contains the source files for [Percona Distribution for PostgreSQL documentation :octicons-link-external-16: :octicons-link-external-16:](httpss://www.percona.com/doc/postgresql/13/index.html). The documentation is written in [reStructured text markup language :octicons-link-external-16: :octicons-link-external-16:](httpss://docutils.sourceforge.io/rst.html) and is created using [Sphinx Python Documentation Generator :octicons-link-external-16: :octicons-link-external-16:](httpss://www.sphinx-doc.org/en/master/).

## Contributing

We welcome all contributions and are always looking for new members that are as dedicated to serving the community as we are. You can reach out to us using our [forums](https://forums.percona.com/c/postgresql/25) and [Jira issue tracker](https://jira.percona.com/projects/DISTPG/issues/DISTPG-16?filter=allopenissues).
We welcome all contributions and are always looking for new members that are as dedicated to serving the community as we are. You can reach out to us using our [forums :octicons-link-external-16: :octicons-link-external-16:](httpss://forums.percona.com/c/postgresql/25) and [Jira issue tracker :octicons-link-external-16: :octicons-link-external-16:](httpss://jira.percona.com/projects/DISTPG/issues/DISTPG-16?filter=allopenissues).

For how to contribute to documentation, read the [Contributing guide](https://github.com/percona/postgresql-docs/blob/13/CONTRIBUTING.md).
<<<<<<< HEAD
For how to contribute to documentation, read the [Contributing guide :octicons-link-external-16:](httpss://github.com/percona/postgresql-docs/blob/13/CONTRIBUTING.md).
=======
For how to contribute to documentation, read the [Contributing guide :octicons-link-external-16: :octicons-link-external-16:](httpss://github.com/percona/postgresql-docs/blob/16/CONTRIBUTING.md).
>>>>>>> 9ee26788... Restructured docs
## License

Percona Distribution for PostgreSQL documentation is licensed under the [PostgreSQL license](https://opensource.org/licenses/postgresql).
Percona Distribution for PostgreSQL documentation is licensed under the [PostgreSQL license :octicons-link-external-16: :octicons-link-external-16:](httpss://opensource.org/licenses/postgresql).
36 changes: 9 additions & 27 deletions docs/apt.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install Percona Distribution for PostgreSQL on Debian and Ubuntu

This document describes how to install Percona Server for PostgreSQL from Percona repositories on DEB-based distributions such as Debian and Ubuntu. [Read more about Percona repositories :material-arrow-top-right:](repo-overview.md).
This document describes how to install Percona Server for PostgreSQL from Percona repositories on DEB-based distributions such as Debian and Ubuntu. [Read more about Percona repositories](repo-overview.md).

## Preconditions

Expand All @@ -11,7 +11,7 @@ This document describes how to install Percona Server for PostgreSQL from Percon

Run all the commands in the following sections as root or using the `sudo` command:

### Configure Percona repository
### Configure Percona repository {.power-number}

1. Install the `percona-release` repository management tool to subscribe to Percona repositories:

Expand Down Expand Up @@ -53,6 +53,9 @@ Run all the commands in the following sections as root or using the `sudo` comma

=== "Install packages individually"

Run the following commands:
{.power-number}

1. Install the PostgreSQL server package:

```{.bash data-prompt="$"}
Expand Down Expand Up @@ -146,31 +149,10 @@ The installation process automatically initializes and starts the default databa
$ sudo systemctl status postgresql.service
```

### Connect to the PostgreSQL server

By default, `postgres` user and `postgres` database are created in PostgreSQL upon its installation and initialization. This allows you to connect to the database as the `postgres` user.

```{.bash data-prompt="$"}
$ sudo su postgres
```

Open the PostgreSQL interactive terminal:

```{.bash data-prompt="$"}
$ psql
```

!!! hint

You can connect to `psql` as the `postgres` user in one go:
Congratulations! Your Percona Distribution for PostgreSQL is up and running.

```{.bash data-prompt="$"}
$ sudo su - postgres -c psql
```
## Next steps

To exit the `psql` terminal, use the following command:

```{.bash data-prompt="$"}
$ \q
```
[Enable extensions :material-arrow-right:](enable-extensions.md){.md-button}

[Connect to PostgreSQL :material-arrow-right:](connect.md){.md-button}
74 changes: 74 additions & 0 deletions docs/connect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Connect to the PostgreSQL server

With PostgreSQL server up and running, let's connect to it.

By default, the `postgres` user and the `postgres` database are created in PostgreSQL upon its installation and initialization. This allows you to connect to the database as the `postgres` user.
{.power-number}

1. Switch to the `postgres` user.

```{.bash data-prompt="$"}
$ sudo su postgres
```

2. Open the PostgreSQL interactive terminal `psql`:

```{.bash data-prompt="$"}
$ psql
```

<i info>:material-information: Hint:</i> You can connect to `psql` as the `postgres` user in one go:

```{.bash data-prompt="$"}
$ sudo su - postgres -c psql
```


## Basic `psql` commands

While connected to PostgreSQL, let's practice some basic `psql` commands to interact with the database:
{.power-number}
1. List databases:
```{.bash data-prompt="$"}
$ \l
```
2. Display tables in the current database:
```{.bash data-prompt="$"}
$ \dt
```
3. Display columns in a table
```{.bash data-prompt="$"}
$ \d <table_name>
```
4. Switch databases
```{.bash data-prompt="$"}
$ \c <database_name>
```
5. Display users and roles
```{.bash data-prompt="$"}
$ \du
```
6. Exit the `psql` terminal:
```{.bash data-prompt="$"}
$ \q
```
To learn more about using `psql`, see [`psql` :octicons-link-external-16:](https://www.postgresql.org/docs/current/app-psql.html) documentation.
Congratulations! You have connected to PostgreSQL and learned some essential `psql` commands.
## Next steps
[Manipulate data in PostgreSQL :material-arrow-right:](crud.md){.md-button}
112 changes: 112 additions & 0 deletions docs/crud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Manipulate data in PostgreSQL

On the previous step, you have [connected to PostgreSQL](connect.md) as the superuser `postgres`. Now, let's insert some sample data and operate with it in PostgreSQL.

## Create a database

Let's create the database `test`. Use the CREATE DATABASE command:

```sql
CREATE DATABASE test;
```

## Create a table

Let's create a sample table `Customers` in the `test` database using the following command:

```sql
CREATE TABLE customers (
id SERIAL PRIMARY KEY, -- 'id' is an auto-incrementing integer
first_name VARCHAR(50), -- 'first_name' is a string with a maximum length of 50 characters
last_name VARCHAR(50), -- 'last_name' is a string with a maximum length of 50 characters
email VARCHAR(100) -- 'email' is a string with a maximum length of 100 characters
);
```

<i info>:material-information: Hint:</i>Having issues with table creation? Check our [Troubleshooting guide](troubleshooting.md)

## Insert the data

Populate the table with the sample data as follows:

```sql
INSERT INTO customers (first_name, last_name, email)
VALUES
('John', 'Doe', '[email protected]'), -- Insert a new row
('Jane', 'Doe', '[email protected]');
('Alice', 'Smith', '[email protected]');
```

## Query data

Let's verify the data insertion by querying it:

```sql
SELECT * FROM customers;
```

??? example "Expected output"

```{.sql .no-copy}
id | first_name | last_name | email
----+------------+-----------+-------------------------
1 | John | Doe | [email protected]
2 | Jane | Doe | [email protected]
3 | Alice | Smith | [email protected]
(3 rows)
```

## Update data

Let's update John Doe's record with a new email address.

1. Use the UPDATE command for that:

```sql
UPDATE customers
SET email = '[email protected]'
WHERE first_name = 'John' AND last_name = 'Doe';
```

2. Query the table to verify the updated data:

```sql
SELECT * FROM customers WHERE first_name = 'John' AND last_name = 'Doe';
```

??? example "Expected output"

```{.sql .no-copy}
id | first_name | last_name | email
----+------------+-----------+-------------------------
2 | Jane | Doe | [email protected]
3 | Alice | Smith | [email protected]
1 | John | Doe | [email protected]
(3 rows)
```

## Delete data

Use the DELETE command to delete rows. For example, delete the record of Alice Smith:

```sql
DELETE FROM Customers WHERE first_name = 'Alice' AND last_name = 'Smith';
```

If you wish to delete the whole table, use the `DROP TABLE` command instead as follows:

```sql
DROP TABLE customers;
```

To delete the whole database, use the DROP DATABASE command:

```sql
DROP DATABASE test;
```

Congratulations! You have used basic create, read, update and delete (CRUD) operations to manipulate data in Percona Distribution for PostgreSQL. To deepen your knowledge, see the [data manipulation :octicons-link-external-16:](https://www.postgresql.org/docs/{{pgversion}}/dml.html) section in PostgreSQL documentation.

## Next steps

[What's next?](whats-next.md)(.md-button)
Loading

0 comments on commit 18dab7e

Please sign in to comment.