Create Table in SQL

Create Table and Insert in SQL

Create Table in SQL

Let's create a table called book with the following fields:

  1. bookname
  2. price
  3. subject

The SQL query to create the table is:

CREATE TABLE book (bookname VARCHAR(10), price INT, subject VARCHAR(10));
Create Table Screenshot

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.

Insert Screenshot 1
Insert Screenshot 2
Insert Screenshot 3
Insert Screenshot 4
Insert Screenshot 5

Post a Comment

0 Comments

Me