![]() After filling all the details, click on the Apply button.Ħ. The following screen explains it more clearly. Here, the column name contains many attributes such as Primary Key(PK), Not Null (NN), Unique Index (UI), Binary(B), Unsigned Data type(UN), Auto Incremental (AI), etc. Click inside the middle window and fill the column details. Here, we will enter the table name ( for example, employee_table) and use default collation and engine.ĥ. On the new table screen, we need to fill all the details to create a table. We can also click on create a new table icon (shown in red rectangle) to create a table.Ĥ. Select Tables sub-menu, right-click on it, and select Create Table option. These sub-menus are Tables, Views, Functions, and Stored Procedures, as shown in the below screen.ģ. Select the database, double click on it, and we will get the sub-menu under the database. Now we are ready to select the database in which a table is created.Ģ. Here, we can see all the previously created databases. ![]() Go to the Navigation tab and click on the Schema menu. Now do the following steps for table creation:ġ. To create a new database using this tool, we first need to launch the MySQL Workbench and log in using the username and password that you want. It is a visual GUI tool used to create databases, tables, indexes, views, and stored procedures quickly and efficiently. It will look like this: Create Table Using MySQL Workbench Here, we are going to create a table name "employee_table" in the database "employeedb" using the following statement: ![]() Now open the database in which you want to create a table. Open the MySQL console and write down the password, if we have set during installation. Let us understand how to create a table into the database with the help of an example. It specifies the table constraints such as PRIMARY KEY, UNIQUE KEY, FOREIGN KEY, CHECK, etc. The syntax of column definition is as follows:Ĭolumn_name1 data_type(size) The columns in table definition are separated by the comma operator. It specifies the name of the column along with data types for each column. The IF NOT EXIST clause avoids an error when we create a table into the selected database that already exists. It should be unique in the MySQL database that we have selected. The following syntax is used to create a unique key in MySQL.The parameter descriptions of the above syntax are as follows: Parameter It can contain null value into the table.It also works with a foreign key in preserving the uniqueness of a table.It stores only distinct values that maintain the integrity and reliability of the database for accessing the information in an organized way.It is useful in preventing the two records from storing identical values into the column.It ensures the integrity of the column or group of columns to store different values into a table. It can accept a null value, but MySQL allowed only one null value per column. MySQL allows us to use more than one column with UNIQUE constraint in a table. For example, the email addresses and roll numbers of students in the "student_info" table or contact number of employees in the "Employee" table should be unique. It means a column cannot stores duplicate values. A unique key in MySQL is a single field or combination of fields that ensure all values going to store into the column will be unique.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |