[DMDB] SQL intro (DML, DDL)

This commit is contained in:
2026-06-22 16:45:25 +02:00
parent cf0bdbaff8
commit 2b066eab3c
11 changed files with 58 additions and 7 deletions
+3
View File
@@ -0,0 +1,3 @@
ALTER TABLE TableName ADD COLUMN (col integer);
ALTER TABLE TableName ADD COLUMN (AnotherColumn integer default "");
ALTER TABLE TableName DROP COLUMN AnotherColumn;
+2 -2
View File
@@ -1,6 +1,6 @@
CREATE TABLE TableName (
Attribute integer,
OtherAttribute varchar (30),
NextAttribute character (2) default "AP",
PRIMARY KEY (Attribute)
NextAttribute character (2) default "AP", -- default value, if unset on insert
PRIMARY KEY (Attribute) -- primary key, as in RA
);
+1
View File
@@ -0,0 +1 @@
DROP TABLE TableName;
+11
View File
@@ -0,0 +1,11 @@
INSERT INTO TableName (
Attribute,
OtherAttribute
) VALUES ( 1000, 'Value' );
DELETE FROM TableName WHERE Attribute > 50;
UPDATE TableName SET Attribute = Attribute + 1;
-- Import data from a CSV file (this is pgsql specific syntax)
COPY TableName FROM '/data.csv' WITH FORMAT csv;