Nodejs MySql Create Table

In this tutorial you will learn about the Nodejs MySql Create Table and its application with practical example.

Node.js MySql Create Table

MySQL Database Table can simply be created using “CREATE TABLE” statement.

Example :- Let’s create MySQL database Table named as “employees” under “nodemysql” database.

Step 1:- Let’s, create a node_mysql_create_tbl.js file and put the following code in it –

Step 2:- Save the code and open the terminal again, and type the following command in order to run the file.

you will see following output on terminal –

Node.js MySql Create Table 1

Node.js MySql Create Table 1

Node.js MySql Create Table 2

Node.js MySql Create Table 2

Add Columns to existing Table

A column can easily be added to an existing MySQL Table using the “ALTER TABLE” statement.

Example :- Let’s add “emp_salary” to database Table “employees”.

Step 1:- Let’s, create a node_mysql_alter_tbl.js file and put the following code in it –

Step 2:- Save the code and open the terminal again, and type the following command in order to run the file.

you will see following output on terminal –

Node.js MySql Alter Table 1

Node.js MySql Alter Table 1

Node.js MySql Alter Table 2

Node.js MySql Alter Table 2

 

In this tutorial we have learn about the Nodejs MySql Create Table and its application with practical example. I hope you will like this tutorial.