Hello World Table
Objective
Create your first AIDB table with basic data types. This is the essential starting point for learning AIDB SQL.
Step 1: Create a Simple Table
Create a basic table with common data types.
CREATE TABLE hello_world (
id INTEGER PRIMARY KEY,
name VARCHAR(100) NOT NULL,
message TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
Step 2: Insert Your First Records
Add some sample data to your table.
INSERT INTO hello_world (id, name, message) VALUES
(1, 'Alice', 'Hello from AIDB!'),
(2, 'Bob', 'Welcome to the database'),
(3, 'Charlie', 'SQL is fun!');
Step 3: Query Your Data
Retrieve the data you just inserted.
SELECT * FROM hello_world;
Step 4: Filter with WHERE Clause
Query specific records using conditions.
SELECT name, message
FROM hello_world
WHERE id = 1;
Step 5: Update a Record
Modify existing data in your table.
UPDATE hello_world
SET message = 'Updated greeting!'
WHERE name = 'Alice';
Step 6: Verify the Update
Check that the update was applied.
SELECT * FROM hello_world WHERE name = 'Alice';
Cleanup (Optional)
Remove the table when done practicing.
DROP TABLE IF EXISTS hello_world;
Expected Outcomes
- Table
hello_worldcreated successfully - 3 records inserted
- SELECT returns all records with timestamps
- UPDATE modifies Alice's message
- Data persists across queries
Key Concepts Learned
- CREATE TABLE syntax
- Basic data types: INTEGER, VARCHAR, TEXT, TIMESTAMP
- PRIMARY KEY constraint
- DEFAULT values
- INSERT, SELECT, UPDATE operations
- WHERE clause filtering