Create Table in SQL
Let's create a table called book with the following fields:
- bookname
- price
- subject
The SQL query to create the table is:
CREATE TABLE book (bookname VARCHAR(10), price INT, subject VARCHAR(10));
Insert Statements
Now let's insert some records into our book table:
INSERT INTO book VALUES ('basic c', 250, 'c');
This inserts values in the exact order of the table columns.
INSERT INTO book (price, subject, bookname) VALUES (300, 'c++', 'basic cpp');
In this one, we’re specifying a different order for the columns explicitly.
INSERT INTO book VALUES ('bookname', 'price', 'subject');
Note: This will insert the literal text "bookname", "price", and "subject" as values into the table.
0 Comments