


If we issue " USE southwind" to set southwind as the default database, we can simply call the table as " products". In our example, we have a database named " southwind" with a table named " products". But you need to use the fully-qualified databaseName.tableName to reference a table NOT in the default database. You can reference a table in the default database using tableName directly. The command " USE databaseName" sets a particular database as the default (or current) database. To check the version of your MySQL server, issue query " SELECT version()". */ is known as version comment, which will only be run if the server is at or above this version number 4.01.00. MySQL multi-line comments are enclosed within /* and */ end-of-line comments begins with - (followed by a space) or #. You can include blanks and special characters or use MySQL keyword as identifier by enclosing it with a pair of back-quote, in the form of ` name`.įor robustness, the SHOW command back-quotes all the identifiers, as illustrated in the above example. Unquoted names or identifiers (such as database name, table name and column name) cannot contain blank and special characters, or crash with MySQL keywords (such as ORDER and DESC). (Try comparing the outputs produced by ' ' and \G.) We use \G (instead of ' ') to display the results vertically.
#Mysql delete column full#
You can issue a " SHOW CREATE DATABASE databaseName" to display the full command and check these default values. The CREATE DATABASE commands uses some defaults. IMPORTANT: Use SQL DROP (and DELETE) commands with extreme care, as the deleted entities are irrecoverable. Mysql> DROP DATABASE IF EXISTS southwind Mysql> CREATE DATABASE IF NOT EXISTS southwind You could optionally apply condition " IF EXISTS" or " IF NOT EXISTS" to these commands. You can create a new database using SQL command " CREATE DATABASE databaseName" and delete a database using " DROP DATABASE databaseName". We shall begin with the first table called " products" with the following columns (having data types as indicated) and rows: Database: southwindĬreating and Deleting a Database - CREATE DATABASE and DROP DATABASE Let's call our database " southwind" (inspired from Microsoft's Northwind Trader sample database). 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
#Mysql delete column manual#
Summary of MySQL Commands Used in this Tutorialįor detailed syntax, check MySQL manual "SQL Statement Syntax".
#Mysql delete column how to#
Read " How to Install MySQL and Get Started" on how to install, customize, and get started with MySQL.
