A product sales database typically consists of many tables, e.g., products, customers, suppliers, orders, payments, employees, among others. Let us begin with a simple example - a product sales database. A " test" database is provided during installation for your testing.
The databases " mysql", " information_schema" and " performance_schema" are system databases used internally by MySQL. You can use SHOW DATABASES to list all the existing databases in the server. Hence, it is best to treat identifiers as case-sensitive. The names or identifiers (database names, table names, column names, etc.) are case-sensitive in some systems, but not in other systems. For clarity, they are shown in uppercase. The SQL keywords and commands are NOT case-sensitive. A table is made up of columns (or fields) and rows ( records). Each database consists of one or more tables. SHOW WARNINGS - Show the warnings of the previous statement An Example for the Beginners (But NOT for the dummies)Ī MySQL database server contains many databases (or schemas).
, columnNValue) - Insert on selected Columns VALUES ( column1Value, column2Value.) - Insert on all Columns SHOW CREATE TABLE tableName - Show the CREATE TABLE statement for this tableName - Row-Level Modify a table, e.g., ADD COLUMN and DROP COLUMNĪLTER TABLE tableName ADD columnDefinitionĪLTER TABLE tableName ADD FOREIGN KEY ( columnNmae) REFERENCES tableName ( columnNmae) ALTER TABLE tableName DROP FOREIGN KEY constraintName SHOW TABLES - Show all the tables in the default databaseĭESCRIBE|DESC tableName - Describe the details for a tableĪLTER TABLE tableName. įOREIGN KEY ( columnNmae) REFERENCES tableName ( columnNmae) SHOW CREATE DATABASE databaseName - Show the CREATE DATABASE statement - Table-LevelĬolumnName columnType columnAttribute. SELECT DATABASE() - Show the default database USE databaseName - Set the default (current) database SHOW DATABASES - Show all the databases in this server Database-LevelĭROP DATABASE databaseName - Delete the database (irrecoverable!)ĭROP DATABASE IF EXISTS databaseName - Delete if it existsĬREATE DATABASE databaseName - Create a new databaseĬREATE DATABASE IF NOT EXISTS databaseName - Create only if it does not exists
Summary of MySQL Commands Used in this Tutorialįor detailed syntax, check MySQL manual "SQL Statement Syntax".
I have good news, you can easily extract schema and share in convenient, searchable HTML documentation in minutes with Dataedo.Read " How to Install MySQL and Get Started" on how to install, customize, and get started with MySQL. Make sure you didn't make any other unwanted changes as any change to the schema will also be applied to the database.īonus: Share database schema with comments in HTMLĮxploring schema of MySQL database and reading comments in is not most convenient with MySQL Workbench. Make sure to save changes with the Apply button. To change column comment you need to first select a column from the grid in the middle of the form (it's attributes will appear at the bottom of the form) and you will be able to edit commetns in the Comments field (green rectangle). You can edit table description in Comments field on the top (blue rectangle). It will open a new tab in the main pane (right-hand side of the screen) with the editor. Select table, click right mouse button and choose Alter table. To edit comments in the specific table, you need to enter into edit mode. If in the last step you didn't see any comments it's probably because there were none entered. To view comments for columns go to Columns tab, and comments will be visible in the last column in the grid. It will open a new tab in main pane (right-hand side of the screen).Ĭomment assigned to your table will be visible at the bottom of the first tab called Info, along with other table metadata. To view comments for a specific table, click right mouse button and choose Table Inspector option. I assume you are already connected to your database and schema and found a list of tables (lower left side of the screen below). Let's start with finding existing comments.
In this tutorial, I would like to show you how to view and edit table and column comments with MySQL Workbench - a free MySQL development and management tool from Oracle. If used, this is useful for understanding database schema and meaning of data elements. MySQL, like most databases, allows you to add comments to each table and column.