Download presentation
Presentation is loading. Please wait.
1
Database Design and Development
SQL - INSERT
2
Learning Intention I will learn how to use SQL to INSERT data into table.
3
INSERTing with SQL Use an INSERT statement to add records to a database table. The statement is followed by the table name and then the VALUES statement, followed by the data in brackets separated by commas. INSERT INTO tableName (field1, field2) VALUES (field1value1, field2value2);
4
INSERTing with SQL If you are inserting a value into every field in the table you don’t need to specify field names – you just need to get the values in the order of the fields e.g. INSERT INTO Resort VALUES (104, "Troon", "coastal", Yes);
5
INSERTing with SQL If you are only inserting values into some of the fields then you must specify the field names. e.g. INSERT INTO Resort (resortID, town) VALUES (105, “Dundee");
6
INSERTing with SQL Rules:
When inserting, required fields must be given a value Cannot insert a record which: violates a Primary Key (no duplicates) violates a Foreign Key (there must be a corresponding value in the PK in the linked table).
7
Pupil Task Complete the following: SQL Booklet Task 6
8
Success Criteria I can create SQL INSERT statements to add data to a table.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.