
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Can we use {} while creating a MySQL table?
No, you need to use open and close parenthesis like this ( ) while creating a table. Use the below syntax −
CREATE TABLE IF NOT EXISTS yourTableName ( yourColumnName1 dataType1, . . . . . N );
Let us first create a table −
mysql> CREATE TABLE IF NOT EXISTS DemoTable ( CustomerId int, CustomerName varchar(20), CustomerAge int , PRIMARY KEY(CustomerId) ); Query OK, 0 rows affected (0.58 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(1,'Chris',25); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(2,'Robert',34); Query OK, 1 row affected (0.15 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
+------------+--------------+-------------+ | CustomerId | CustomerName | CustomerAge | +------------+--------------+-------------+ | 1 | Chris | 25 | | 2 | Robert | 34 | +------------+--------------+-------------+ 2 rows in set (0.00 sec)
- Related Articles
- How can we use logical operators while creating MySQL views?
- How can we use a combination of logical operators while creating MySQL views?
- While creating a MySQL table use the reserved keyword ‘Key’
- Can we use INTERVAL keyword while inserting date records in a MySQL table?
- What is MySQL NOT NULL constraint and how can we declare a field NOT NULL while creating a table?
- What is MySQL GENERATED COLUMN and how to use it while creating a table?
- Set AUTO_INCREMENT in a table while creating it in MySQL?
- Will MySQL work if we won’t include the size of VARCHAR while creating a new table?
- Can we use the word user for a MySQL table?
- How can we use WHERE condition when creating a table with CTAS (Create Table as Selected) script?
- Set DEFAULT values for columns while creating a table in MySQL
- Can we use “year” as a column came in a MySQL Table?
- What is the use of DEFAULT constraint? How can it be applied to a column while creating a table?
- How can we use MySQL EXPORT_SET() function with column of a table?
- Set options while creating a MySQL table. Display the same options as well

Advertisements