Set - 2

Question 1 :

How do you get the month from a timestamp?

Answer :

SELECT MONTH(techpreparation_timestamp) from techpreparation_questions;

Question 2 :

How do you offload the time/date handling to MySQL?

Answer :

SELECT DATE_FORMAT(techpreparation_timestamp, '%Y-%m-%d') from techpreparation_questions; A similar TIME_FORMAT function deals with time.

Question 3 :

How do you add three minutes to a date?

Answer :

ADDDATE(techpreparation_publication_date, INTERVAL 3 MINUTE)

Question 4 :

What's the difference between Unix timestamps and MySQL timestamps?

Answer :

Internally Unix timestamps are stored as 32-bit integers, while MySQL timestamps are stored in a similar manner, but represented in readable YYYY-MM-DD HH:MM:SS format.

Question 5 :

How do you convert between Unix timestamps and MySQL timestamps?

Answer :

UNIX_TIMESTAMP converts from MySQL timestamp to Unix timestamp, FROM_UNIXTIME converts from Unix timestamp to MySQL timestamp.

Question 6 :

What are ENUMs used for in MySQL?

Answer :

You can limit the possible values that go into the table. CREATE TABLE months (month ENUM 'January', 'February', 'March',…); INSERT months VALUES ('April');

Question 7 :

How are ENUMs and SETs represented internally?

Answer :

As unique integers representing the powers of two, due to storage optimizations.

Question 8 :

How do you start and stop MySQL on Windows?

Answer :

net start MySQL, net stop MySQL

Question 9 :

How do you start MySQL on Linux?

Answer :

/etc/init.d/mysql start

Question 10 :

Explain the difference between mysql and mysql interfaces in PHP?

Answer :

mysqli is the object-oriented version of mysql library functions.

Question 11 :

What's the default port for MySQL Server?

Answer :


Question 12 :

What does tee command do in MySQL?

Answer :

tee followed by a filename turns on MySQL logging to a specified file. It can be stopped by command note.

Question 13 :

Can you save your connection settings to a conf file?

Answer :

Yes, and name it ~/.my.conf. You might want to change the permissions on the file to 600, so that it's not readable by others.

Question 14 :

How do you change a password for an existing user via mysqladmin?

Answer :

mysqladmin -u root -p password "newpassword"

Question 15 :

Use mysqldump to create a copy of the database?

Answer :

mysqldump -h mysqlhost -u username -p mydatabasename > dbdump.sql

Question 16 :

Have you ever used MySQL Administrator and MySQL Query Browser?

Answer :

Describe the tasks you accomplished with these tools.

Question 17 :

What are some good ideas regarding user security in MySQL?

Answer :

There is no user without a password. There is no user without a user name. There is no user whose Host column contains % (which here indicates that the user can log in from anywhere in the network or the Internet). There are as few users as possible (in the ideal case only root) who have unrestricted access.

Question 18 :

Explain the difference between MyISAM Static and MyISAM Dynamic. ?

Answer :

In MyISAM static all the fields have fixed width. The Dynamic MyISAM table would include fields such as TEXT, BLOB, etc. to accommodate the data types with various lengths. MyISAM Static would be easier to restore in case of corruption, since even though you might lose some data, you know exactly where to look for the beginning of the next record.

Question 19 :

What does myisamchk do?

Answer :

It compressed the MyISAM tables, which reduces their disk usage.

Question 20 :

Explain advantages of InnoDB over MyISAM?

Answer :

Row-level locking, transactions, foreign key constraints and crash recovery.

Question 21 :

Explain advantages of MyISAM over InnoDB?

Answer :

Much more conservative approach to disk space management - each MyISAM table is stored in a separate file, which could be compressed then with myisamchk if needed. With InnoDB the tables are stored in tablespace, and not much further optimization is possible. All data except for TEXT and BLOB can occupy 8,000 bytes at most. No full text indexing is available for InnoDB. TRhe COUNT(*)s execute slower than in MyISAM due to tablespace complexity.

Question 22 :

What are HEAP tables in MySQL?

Answer :

HEAP tables are in-memory. They are usually used for high-speed temporary storage. No TEXT or BLOB fields are allowed within HEAP tables. You can only use the comparison operators = and <=>. HEAP tables do not support AUTO_INCREMENT. Indexes must be NOT NULL.

Question 23 :

How do you control the max size of a HEAP table?

Answer :

MySQL config variable max_heap_table_size.

Question 24 :

What are CSV tables?

Answer :

Those are the special tables, data for which is saved into comma-separated values files. They cannot be indexed.

Question 25 :

Explain federated tables. ?

Answer :

Introduced in MySQL 5.0, federated tables allow access to the tables located on other databases on other servers.