Quantcast
Viewing all articles
Browse latest Browse all 5

Basic Database Creation 2

On Index tab, make sure idpersons is checked as this is the primary key of this table. This primary key will use later on your query to relate to other tables on your database, as we are creating a relational database. and then click apply, apply sql, the MySQL Work Bench automatically generate a script as shown below:
 CREATE TABLE `testdb`.`persons` (
      `idpersons` INT NOT NULL ,
      `lastname` VARCHAR(45) NULL ,
      `fname` VARCHAR(45) NULL ,
      `address` VARCHAR(100) NULL ,
      PRIMARY KEY (`idpersons`)
 )ENGINE = MyISAM;
 
Click Apply SQL so that table will be created. you noticed that after creating the table, the table persons does not appeared on the list, all you have to do is right click the testdb schema (database name) and select refresh all, the table persons is now visible. to edit the existing table you can select any on the drop down menu when you right click the table name as shown below:
Edit Table Data = To Insert or add new record
Copy To Clipboard = To copy the name of the table
Send to SQL Editor = Send to SQL editor a sql statement such as Select, Insert, update delete, create statement. When you click the Select All Statement this sql will be displayed as shown below in your Work bench’s SQL Query Editor:
SELECT `persons`.`idpersons`, 
 `persons`.`lastname`, 
 `persons`.`fname`, 
 `persons`.`address` 
 FROM `testdb`.`persons`; 

Alter table = This will alter or modify the table’s structure.
Create table = This will create new table.
Drop Table = This will going the delete the current selected table.
Refresh All = will refresh or synchronize Work Bench with MySQL.

Keywords: , , , ,

Other reading this article are also reading these:


Viewing all articles
Browse latest Browse all 5

Trending Articles