- This is an advanced treatment of Database Control using queries instead of SQLite Manager tabs.
 
Enter the data directly
Show students the SQLite Manager
Execute SQLtab.
CREATE TABLE- name table
 - list field names and data types
        
- may constrain data values
            
NullUnique- value length
 
 
 - may constrain data values
            
 
CREATE TABLE Experiment(
  LoginID TEXT,
  Project TEXT,
  Experiment INTEGER,
  Hours REAL,
  ExperimentDate TEXT
);
- We realized we want to add some more specific configuration to the table.
 - Restart requires:
 
DROP TABLE Experiment
- Add unique 
RecordIDfield to be the primary key - Prevent important values from being 
NULL 
CREATE TABLE Experiment(
  RecordID INTEGER PRIMARY KEY AUTOINCREMENT,
  LoginID TEXT NOT NULL,
  Project TEXT NOT NULL,
  Experiment INTEGER NOT NULL,
  Hours REAL,
  ExperimentDate TEXT(10)
);
- Add new records
    
INSERT INTO- If values for all fields are being added:
 
 
INSERT INTO Experiment 
VALUES (1, 'ipav', 'Conditioning', 1, 3.2, '1910-07-05');
- Add incomplete records
    
- If you are only adding values for some of the possible fields
        
- Indicate which fields the values correspond to:
 
 
 - If you are only adding values for some of the possible fields
        
 
INSERT INTO Experiment (LoginID, Project, Experiment, Hours, 
ExperimentDate) 
VALUES ('jane', 'Great Apes', 1, 7, '1967-04-13');
Modifying existing records
UPDATE- name table
 SETvalues of any or all of the fieldsWHEREconditions are met- Don’t forget the 
WHEREclause or the update statement will update all of the records in the database. 
- Don’t forget the 
 
UPDATE Experiment 
SET Hours=7.5, ExperimentDate='1967-04-19' 
WHERE RecordID=2;
Deleting records
DELETE- name table
 WHEREconditions are met- Don’t forget the 
WHEREclause or the update statement will update all of the records in the database. 
- Don’t forget the 
 
DELETE FROM Experiment 
WHERE LoginID='ipav';
