Learn What is Database Table? How to Create a Database Table using SQL?

Learn What is Database Table? How to Create a Database Table using SQL?


In this lecture we will Learn how to create the database table using SQL statement. The “CREATE TABLE” statement is used to create a database table. A valid database table name may contain only letters, numbers and underscore symbol. The database table names are case insensitive. That is table name ‘students’ (all small letters) is similar to the table name ‘StuDenTs’ (the letters S, D and T are capital). A single database must contain a unique table name, while in multiple databases, the same table name can exist in another database. Here is the SQL statement to create new database table. Lets Learn how to create the database table with some practical examples. I’ve logged in my MySQL database server by using my root username and password. I’ll Select ‘school’ database using SQL statement, “USE school;” and display all the tables in ‘school’ database using SQL statement, “SHOW TABLES;” The system returns all the table names stored in the selected database. Lets create a new table called ‘students3’ with only 2 columns, studentid and firstname. The SQL statement will be, CREATE TABLE students3 ( studentid SMALLINT(5), firstname VARCHAR(20) ); Press enter to execute the SQL statement, and we get ‘Query OK, 0 rows affected’ message. If we display all the tables again using SQL statement, “SHOW TABLES;” We can see the new table named ‘students3’ is successfully created. We can display the information about table structure by using SQL statement, “DESCRIBE students3;” or using SQL statement, “EXPLAIN students3;” And we get all information about the table like column name, data types and SQL Constraints.

Danny Hutson

1 thought on “Learn What is Database Table? How to Create a Database Table using SQL?

Leave a Reply

Your email address will not be published. Required fields are marked *