Insert, Update, Delete

Introductie tot SQL Server

John MacKintosh

Instructor

INSERT

INSERT INTO table_name
INSERT INTO table_name (col1, col2, col3)
INSERT INTO table_name (col1, col2, col3) 
VALUES 
  ('value1', 'value2', value3)
Introductie tot SQL Server

INSERT SELECT

INSERT INTO table_name (col1, col2, col3) 
SELECT 
  column1, 
  column2, 
  column3 
FROM other_table 
WHERE 
  -- conditions apply
  • Gebruik geen SELECT *
  • Wees specifiek als de tabelstructuur kan wijzigen
Introductie tot SQL Server

UPDATE

UPDATE table 
SET column = value 
WHERE 
  -- Condition(s);
  • Vergeet de WHERE-clausule niet!
UPDATE table 
SET 
  column1 = value1, 
  column2 = value2 
WHERE 
  -- Condition(s);
Introductie tot SQL Server

DELETE

DELETE 
FROM table 
WHERE 
  -- Conditions
  • Eerst testen!
TRUNCATE TABLE table_name
  • Leegt de hele tabel in één keer

Introductie tot SQL Server

Laten we INSERTEN, UPDATEN en DELETEN!

Introductie tot SQL Server

Preparing Video For Download...