Thursday, May 21, 2015

Creating table in MySQL

I have just successfully created my first table in the newly created MySQL database. I'd like to learn how to create the database and tables from script file, so it will be easier for me to re-create the same database in the web hosting server in future, but now I just learned how to create the table from Visual Studio Server Explorer.

1. Connect to the MySQL database in Visual Studio. (You can read how to do so here.)

2. Expand the database, you'll see these folders: Tables, Views, StoredProcedures, StoredFunctions,UDFs.

3. Right click on the Tables folder and click Create Table.

4. Just define the columns almost as how we do in MS SQL database.


5. To define the Primary Key:
1) In Column Properties, set Allow Nulls to No and Autoincrement to Yes.

2) Highlight the primary key column, select Table Designer in the menu, and click on Set Primary Key.


Note: To define like nvarchar() in MSSQL, here we can set the Data Type as varchar(n) and the Character Set as utf8.

This is how I created my first MySQL table in this application. I am going to explore more and convert my MS SQL database to MySQL database very soon.

No comments:

Post a Comment