![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Should I name the username field in my MySQL table “name” or “user_name”?
Do not prefix table name with field name like user_name. Instead, use user or username.
If you prefix table name, then there may be a chance of ambiguity, so avoid prefixing table name.
Let us first create a table −
mysql> create table user -> ( -> username varchar(20), -> password varchar(20) -> ); Query OK, 0 rows affected (0.66 sec)
Insert some records in the table using insert command −
mysql> insert into user values('John','J_635'); Query OK, 1 row affected (0.34 sec) mysql> insert into user values('Carol','Carol2212'); Query OK, 1 row affected (0.16 sec) mysql> insert into user values('David','@12345678'); Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement −
mysql> select * from user;
This will produce the following output −
+----------+-----------+ | username | password | +----------+-----------+ | John | J_635 | | Carol | Carol2212 | | David | @12345678 | +----------+-----------+ 3 rows in set (0.00 sec)
Advertisements