MySQL Examples for Beginners This basic MySQL query which will help beginners to learn. -- Delete if it exists mysql> DROP DATABASE IF EXISTS databaseName -- Create only if it does not exists mysql> CREATE DATABASE IF NOT EXISTS databaseName -- Set the default (current) database mysql> USE databaseName -- Show the default database mysql> SELECT DATABASE() -- Show the CREATE DATABASE statement mysql> SHOW CREATE DATABASE databaseName -- Show all the tables in the current database. mysql> SHOW TABLES; -- Create the table "products". mysql> CREATE TABLE IF NOT EXISTS products ( productID bigint(11) UNSIGNED NOT NULL AUTO_INCREMENT, productCode CHAR(3) NOT NULL DEFAULT '', name VARCHAR(30) NOT NULL DEFAULT '', quantity INT UNSIGNED NOT NULL DEFAULT 0, price DECIMAL(7,2) NOT NULL DEFAULT 0000.00, PRIMARY KEY (productID) ); -- Describe the fields (columns) of the "products" table mysql> DESCRIBE pro...
Coding Cheatsheets - Learn web development code and tutorials for Software developers which will helps you in project. Get help on JavaScript, PHP, XML, and more.