Interview :: MySQL
- MySQL is a free, fast, reliable, open-source relational database while Oracle is expensive, although they have provided Oracle free edition to attract MySQL users.
- MySQL uses only just under 1 MB of RAM on your laptop, while Oracle 9i installation uses 128 MB.
- MySQL is great for database enabled websites while Oracle is made for enterprises.
- MySQL is portable.
- MySQL is not so efficient for large scale databases.
- It does not support COMMIT and STORED PROCEDURES functions version less than 5.0.
- Transactions are not handled very efficiently.
- The functionality of MySQL is highly dependent on other addons.
- Development is not community-driven.
- CHAR and VARCHAR have differed in storage and retrieval.
- CHAR column length is fixed, while VARCHAR length is variable.
- The maximum no. of character CHAR data types can hold is 255 characters, while VARCHAR can hold up to 4000 characters.
- CHAR is 50% faster than VARCHAR.
- CHAR uses static memory allocation, while VARCHAR uses dynamic memory allocation.
Mysql_connect:
- It opens a new connection to the database.
- Every time you need to open and close the database connection, depending on the request.
- Opens page whenever it is loaded.
Mysql_pconnect:
- In Mysql_pconnect, "p" stands for persistent connection, so it opens the persistent connection.
- The database connection cannot be closed.
- It is more useful if your site has more traffic because there is no need to open and close connection frequently and whenever the page is loaded.
The "i_am_a_dummy flag" enables the MySQL engine to refuse any UPDATE or DELETE statement to execute if the WHERE clause is not present. Hence it can save the programmer from deleting the entire table my mistake if he does not use WHERE clause.
To get current date, use the following syntax:
Install antivirus and configure the operating system's firewall.
Never use the MySQL Server as the UNIX root user.
Change the root username and password Restrict or disable remote access.
Mysqladmin -u root -p password "newpassword".
Actually, both Unix timestamp and MySQL timestamp are stored as 32-bit integers, but MySQL timestamp is represented in the readable format of YYYY-MM-DD HH:MM:SS format.
Let us take a table named the employee.
To find Nth highest salary is:
select distinct(salary)from employee order by salary desc limit n-1,1
if you want to find 3rd largest salary:
select distinct(salary)from employee order by salary desc limit 2,1