

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- How can we use logical operators while creating MySQL views?
- How can we use a combination of logical operators while creating MySQL views?
- Can we use INTERVAL keyword while inserting date records in a MySQL table?
- While creating a MySQL table use the reserved keyword ‘Key’
- What is MySQL GENERATED COLUMN and how to use it while creating a table?
- What is MySQL NOT NULL constraint and how can we declare a field NOT NULL while creating a table?
- Set AUTO_INCREMENT in a table while creating it in MySQL?
- Can we use the word user for a MySQL table?
- Set DEFAULT values for columns while creating a table in MySQL
- How can we use WHERE condition when creating a table with CTAS (Create Table as Selected) script?
- 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?
- Will MySQL work if we won’t include the size of VARCHAR while creating a new table?
- Set options while creating a MySQL table. Display the same options as well
- Creating a table with MySQL - Hibernate
Advertisements