Quản trị bảng trong PostgreSQL bao gồm việc tạo, chỉnh sửa, xóa bảng và quản lý dữ liệu bên trong chúng. Dưới đây là một số tác vụ quản trị cơ bản cho bảng trong PostgreSQL:
Tạo bảng
Để tạo một bảng mới trong PostgreSQL, bạn sử dụng câu lệnh CREATE TABLE. Dưới đây là một ví dụ:
CREATE TABLE employees ( id SERIAL PRIMARY KEY, name VARCHAR(100), age INT, salary NUMERIC(10, 2) );
Trong ví dụ này, chúng ta tạo một bảng employees với các cột id, name, age, và salary.
Xem cấu trúc của bảng
Bạn có thể xem cấu trúc của một bảng bằng cách sử dụng lệnh d trong psql hoặc truy vấn thông tin schema.
d employees dt+
Thêm cột vào bảng
Để thêm một cột mới vào bảng, bạn sử dụng câu lệnh ALTER TABLE. Dưới đây là một ví dụ:
ALTER TABLE employees ADD COLUMN department VARCHAR(50);
Đổi tên bảng
ALTER TABLE employees RENAME TO staff;
Xóa bảng
DROP TABLE employees;
Chỉnh sửa dữ liệu trong bảng
Để thêm, sửa đổi hoặc xóa dữ liệu trong bảng, bạn sử dụng các câu lệnh INSERT, UPDATE, và DELETE.
Insert block dữ liệu vào bảng:
INSERT INTO tab1 (id, data1) SELECT 111, 'chxhcnvn' FROM generate_series(1, 10);
dòng trên sẽ insert 10 records vào bảng.

Bikil - Bikini & Lingerie Fashion Responsive Shopify Theme
Ashi - Yoga Pilates, Fitness Shopify Theme
Minimog - Next-gen Multipurpose Shopify theme grade-A
Download Monitor - CSV Importer
Porto | Multipurpose & WooCommerce Theme
Ninja E-Sport - Gaming Elementor Template Kit
Almighty Wordpress Theme
Seporta - Gym & Fitness Trainer Elementor Template Kit
Finess Elementor Template Kit
Groovy Mega Menu
Lunar - Template Kit for eSport & Gaming
Revision - Optimized Personal Blog WordPress Theme
CheerUp - Food, Blog & Magazine for WordPress
Gymsite - Gym Elementor Template Kit
Menica - Wedding Elementor Template Kit
Fodis - Restaurant & Cafe WordPress Theme
jannifer hamis health coach healthy lifestyle blog
Ohio - Creative Portfolio & Agency WordPress Theme
Academy pro wordpress theme
Adaptable Notes Wordpress Theme
Traveler - Travel Booking WordPress Theme
Gloreya - Food Ordering & Delivery Restaurant WordPress Theme