|
|
Action queries modify the data inside a database.
-
If you want to change data that already exist, use an UPDATE statement.
For example, with the demise of CECE, all IT majors were transferred from
college 30 to college 32 (CAS). So, we could make a query like so:
UPDATE students
SET HomeCollegeID = 32
WHERE HomeCollegeID = 30 AND major = "IT"
-
Note that we use the SQL =, not the Java ==. In SQL, = represents
both equality and assignment.
-
To insert a new record, use the INSERT keyword.
INSERT INTO STUDENTS
VALUES ("Conrad McMasters", "mcmastce", "M", "IT", 32)
-
And, to create a table, use CREATE TABLE.
-
Put each field followed by its type and a comma (if necessary) inside curly
braces.
CREATE TABLE colleges
{
CollegeID INT,
Name VARCHAR(25),
Dean INT
}
JDBC Concepts
|