Master DataGrip: Connect, Insert, Update, and Delete PostgreSQL in Minutes
This guide walks you through using JetBrains DataGrip on AlmaLinux to connect to a PostgreSQL server, then demonstrates step‑by‑step how to insert, modify, and delete records via the graphical interface and optional SQL console, highlighting key settings and safety tips.
Hello, I'm IT Salty Fish. Recently I experimented with PostgreSQL on AlmaLinux using JetBrains DataGrip, which makes database operations much faster, especially for beginners.
1. Connect to PostgreSQL
Open DataGrip, create a new data source by navigating Database → + → Data Source → PostgreSQL, then fill in the Host (e.g., localhost or 127.0.0.1), Port (default 5432), Database name, User, and Password. DataGrip will automatically download the matching JDBC driver. Click Test Connection; if it turns green, click OK to save.
If the connection fails, ensure the PostgreSQL service is running ( systemctl status postgresql ) and that listen_addresses and pg_hba.conf are correctly configured. Also open port 5432 in the firewall ( firewall-cmd ).
2. Insert New Data
Locate your table in the Database panel (e.g., public → Tables → users), open the Data view, and click the large + button at the bottom. A blank row appears; fill the columns (id, name, email) just like an Excel sheet. Then click the Submit button (usually a right‑arrow icon) to execute the generated INSERT statement. You can preview the SQL with the Preview button before submitting.
3. Modify Existing Data
Find the row you want to change (e.g., where name='IT咸鱼'), edit the cell directly (e.g., update the email), and click Submit. DataGrip generates an UPDATE statement that targets only the modified field.
4. Delete Data
Select the row by clicking its leftmost line number, then click the - button or press the Delete key. Confirm the deletion in the popup, and finally click Submit to apply the DELETE statement.
Warning: Deleting without a WHERE clause can remove the entire table. Use precise conditions or write explicit DELETE statements for bulk deletions.
5. Command‑Line Alternative
Open the SQL console by right‑clicking the database connection and choosing New → Query Console, or use shortcuts (Alt+F10 on Windows/Linux, Option+F10 on macOS). Write INSERT, UPDATE, or DELETE statements, then execute with the green Execute button or Ctrl+Enter / Cmd+Enter. Results appear below.
-- Insert (graphical is easier, but CLI works for bulk/complex logic)
INSERT INTO users (name, email) VALUES ('新咸鱼', '[email protected]');
-- Update (graphical edits one field, CLI handles bulk conditions)
UPDATE users SET email = '[email protected]' WHERE name LIKE '%咸鱼%';
-- Delete (graphical for single rows, CLI safer for many)
DELETE FROM users WHERE id = 100; -- always include WHERE!Comments: Use -- for inline notes. Always specify column names in INSERT to avoid errors when the table schema changes. Include a WHERE clause in UPDATE and DELETE to prevent accidental full‑table modifications.
6. Component Notes
DataGrip is a client tool that connects to the PostgreSQL server via JDBC; all SQL runs on the server.
AlmaLinux is the OS hosting PostgreSQL; DataGrip runs on your workstation (Windows/Mac/Linux).
You can run PostgreSQL in a Docker container on AlmaLinux and connect DataGrip to the exposed port (usually 5432).
Keep DataGrip updated for better features; review PostgreSQL release notes before major version upgrades.
JDBC drivers are managed automatically, but older PostgreSQL versions may require a manual driver version.
Summary
Using DataGrip to perform CRUD operations on PostgreSQL is straightforward: connect, insert (+), modify, delete (-), and always click Submit to apply changes. While the GUI speeds up basic tasks, solid SQL fundamentals remain essential for complex queries, batch operations, and performance tuning.
IT Xianyu
We share common IT technologies (Java, Web, SQL, etc.) and practical applications of emerging software development techniques. New articles are posted daily. Follow IT Xianyu to stay ahead in tech. The IT Xianyu series is being regularly updated.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
