Do you know that? Freelance work is the fastest growing sector of the labor market next

See right interview answers on 30 common job interview questions


Collapse | Expand

1. ALTER command to add and drop INDEX in MySQL

Index in a database is used to improve the speed of operations in a table. Index can be done using single or multiple columns.

There are 4 types of index commands to adding indexes to a table:

ALTER TABLE tbl_name ADD PRIMARY KEY (column_list) : Adds a primary key which means adds indexes and does not allow null values.
ALTER TABLE tbl_name ADD UNIQUE index_name (column_list): Creates an index whose values must be null with the exception of NULL values.
ALTER TABLE tbl_name ADD INDEX index_name (column_list): Adds indexes in which one value can appear more than once
ALTER TABLE tbl_name ADD FULLTEXT index_name (column_list): Adds an index for efficient text-searching purpose.

Dropping indexes:
 
To drop a primary key:
ALTER TABLE testalter_tbl DROP PRIMARY KEY;

To drop an index:

DROP INDEX index_name ON tbl_name.

2. COMMIT and ROLLBACK in MySQL

COMMIT: Commit statement commits the current transaction, which means making the changes permanent. A transaction may involve update and or delete and or insert statements. 

ROLLBACK: Rollback statement rolls back the present transaction, which means cancelling a transaction's changes. 

The statement SET AUTOCOMMIT enables or disables the committing transactions automatically for the current session.

3. Describe MySQL Connection using mysql binary.

The MySQL connection using mysql binary can be established by using the following command at os command prompt of unix.

mysql -u root -p

which connects to MySQL and launches mysql> prompt.

4. Describe MySQL Connection using PHP Script.

  Establishing connection to MySQL database using PHP can be done by using  mysql_connect(server,user,passwd,new_link,client_flag).

 Here, server specifies the host name where the databae is present.

User and password is the user name and password to connect.

New_link if specified will not require a connection again.

Client_flag can take a number of values like MySQL_CLIENT_SSL, MYSQL_CLIENT_COMPRESS, MYSQL_CLIENT_IGNORE_SPACE, MYSQL_CLIENT_INTERACTIVE.

It is a good practice to close the connection using mysql_close()

5. Differentiate between FLOAT and DOUBLE.

FLOAT stores floating point numbers with accuracy up to eight places and has four bytes while DOUBLE stores floating point numbers with accuracy upto 18 places and has eight bytes.

6. Discuss about MyISAM Index Statistics Collection.

MyISAM's Index statistics collection is based on a set of rows with the same key prefix value. Here, these set of rows are called as value group. The statistics about the tables is used by the optimizer. The average value of the group size plays an improtant role. The group size is used estimate how many rows must be read for each ref access and how many rows will a particular join will produce. Myisam_stats_method system variable if set as global, affects statistics collection for all tables. 

7. Discuss about MyISAM Key Cache.

MyISAM keeps a key cache to minimize disk I/O. it keeps the most frequently accessed table blocks in memory. For most frequently accessed index blocks, key cache is used. The key cache is not used for data blocks. Multiple threads can access the cache concurrently. The size of the key cache is restricted using key_buffer_size system variable. If the value of this variable is 0, no key cache is used.

8. Explain about MySQL and its features.

MySQL is a relational database management system which is an open source  database.

Features:

  •  Because of its unique storage engine architecture MySQL performance is very  high. 
  •  Supports large number of embedded applications which makes MySql very flexible. 
  •  Use of Triggers, Stored procedures and views which allows the developer to give  a higher productivity. 
  •  Allows transactions to be rolled back, commit and crash recovery. 

9. Explain advantages of InnoDB over MyISAM.

  •  InnoDb supports locking of rows while MyISAM supports only table locking. 
  •  Data integrity is more in InnoDB. 
  •  Transactional nature of InnoDB enables easy and online backups.

10. Explain advantages of MyISAM over InnoDB

The following are the advantages of MyISAM over InnoDB:

- MyISAM tables are stored in separate files in compressed mode, where as InnoDB tables are stored in table space.
- More options for further optimization in MyISAM, where as there is no further optimization possible with InnoDB.
- Data except for TEXT and BLOB can occupy at most 8000 bytes in InnoDB.
- Full text indexing available in MyISAM, where as no full text indexing is available for InnoDB. 
- Count(*) function's execution is slower in InnoDB because of table space complexity.

11. Explain advantages of MyISAM over InnoDB.

  •  Data is not cached by the MySQL query browser. 
  •  MyISAM is a simple storage engine. 
  •  MyISAM provides more optimization. 
  •  MyISAM has a low relative memory use.

12. Explain advantages of MyISAM over InnoDB?

- MyISAM follows a much more conservative approach to disk space management - storing each MyISAM table in a separate file, which can be further compresses, if required. 
- InnoDB stores the tables in tablespace. Further optimization is difficult with them. 

13. Explain MySQL Aggregate Functions.

  Aggregate functions in MySQL are a group of functions that are used to operate  on a set of values. These functions ignore NULL values unless specified.  Functions like AVG(), MIN(), MAX(), COUNT() etc fall under this category. As  they operate on a set of values, if no Group by clause is used, it applies to  all rows. 

14. Explain the difference between BOOL, TINYINT and BIT in MySQL.

BOOL: Used to store Boolean values, 0 being false and 1 being true. MySQL sets them as TINYINT type.
TINYINT: The range of this data type is -128 - +127 or 0 - 256 and occupies 1 byte.
BIT: Bit uses 8 bytes and stores only binary data.

15. Explain the difference between MyISAM Static and MyISAM Dynamic.

MyISAM Static tables have fields of fixed width while the MyISAM Dynamic can accommodate variable lengths such as TEXT, BLOB etc. MyISAM allows easier restoration of data as compared to MyISAM dynamic.

16. Explain the options of myisamchk to improve the performance of a table.

Myisamchk has a couple of options to optimize a table. 

  •  Using myisamchk -r table_name, runs myisamchk in recovery mode. This option combines the fragmented rows and gets rid of wasted space. 
  •  --Analyze, -a is used for analyze the distribution of key values. 
  •  --sort-index, -S - Sorts index tree. 
  •  --sort-records=index_num, -R index_num - sorts recods according to particularr  index.

17. Explain the purpose of max_user_connections.

max_user_connections in MySql is used to limit the resources it limits only the number of simultaneous connections made using a single account. A value of 0 means no limit to the number of connections.

18. How are MySQL timestamps seen to a user?

- MySQL time stamps are seen to a user in a readable format : YYYY-MM-DD HH:MM:SS. 

19. How can you make a database as your current database?

After making a database the first thing which has to be done is to create a table inside the database to test the new database that is being created. The command which is used to do that is:
USE aliendatabase;
This command allows us to make a database which is not a current database as my current. I have to just use the USE variable and the name of the database and it will become active for use.

20. How database are managed?

Database is a collection of data and it is managed by a database server, which is a special program that is also known as MySQL database server. Application that you create usually communicates with the database server in the language which it can understand; mostly SQL language is used for communication. Database server in return interacts with the web server on same server or computer. Database server and web server result in the data which is being shown on the web.

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

- Maximum size of Heap table can be controlled using MySQL config variable called max_heap_table_size.

22. How important is to list the column names when doing an INSERT?

It is not important to list the column names when doing using an INSERT command as you can provide the column information and values in the table in the same order in which they appear in the table structure. It is safer and convenient way to specify the column names as it will keep the count of the column you are visiting. 

23. How is Exception Handling handled in MySQL?

  Exception handling means changing the usual expected flow of the code. This  needs to be done to avoid errors. The exceptions in MySql can be handled using  the following syntax:

 DECLARE handler_type (Continue | Exit) HANDLER FOR condition_value[,...]  sp_statement

Here, whenever an error occurs, the handler type value will decide whether to continue or Exit. Continue will execute the next Sql statement while exit will exit the procedure. Condition_value can take number of levels of categories. set condition is used to define code to be performed if the handler is called. 

24. How is MyISAM table stored?

MyISAM table is stored on disk in three formats. 
- '.frm' file - storing the table definition
- '.MYD' (MYData) - data file 
- '.MYI' (MYIndex) - index file

25. How many TRIGGERS are allowed in MySql table?

MySql table allows following 6 triggers: 

-BEFORE INSERT
-AFTER INSERT
-BEFORE UPDATE
-AFTER UPDATE
-BEFORE DELETE and
-AFTER DELETE

26. How to Check MyISAM Tables for Errors?

Using the -myisamchk table_name command can be used to find all errors. it cannot find corruption that involves only the data file. The different options are:

Myisamchk -m table_name - checks index entries for errors and calculates checksum. This checksum that is calculated for all key values of rows is verified with the keys in the index tree.

Myisamchk -e table_name - performs and extended check. does a complete and thorough check of all data

27. How to connect a PHP script with the MySQL database?

PHP script can be connected with MySQL database by using the function called as mysqli_connect() function. You need to provide the information related to your location, username, and password to the server to get permission to interact with the MySQL database server. When database name will be asked provide the name and it will connect you to the database. 

28. How to find the unique values if the value in the column is repeated?

If the values in the column of a table are repeating and a unique value has to be found then the following command can be used in the query:
SELECT DISTINCT user_firstname FROM users; 
There is another command which can be used to find the command to see the distinct values as:
SELECT COUNT (DISTINCT user_firstname) FROM users;

29. How to take MYSQL database backup?

To take the database backup use the following syntax:
mysqldump --add-drop-table -u [username] -p[password] [database] > [backup_file]
This command will take the database backup by knowing the username and password for the database connection and dropping any table which is being deleted or not in use. It is always a good practice to take the backup of mysql as it contains all the database information that a user can access. While using the command keep a note that there should not be any space between -p switch and password, if there is then you will get a syntax error. 

30. How to use myisamchk to check or repair MyISAM tables?

Myisamchk gets is used to fetch information about the database tables. It is also used to check, repair and optimize the tables. From shell, Myisamchk can be invoked by typing:

Shell> myisamchk [options] tbl_name.

Here options explains what is expected from the Myisamchk.

31. How will you export tables as an XML file in MySQL?

MYSQL's query browser has a provision called ''Export Result Set'' which allows the tables to be exported as XML.

32. How would concatenate strings in MySQL?

With the use of - CONCAT (string1, string2, string3) 

33. How would you enter Characters as HEX Numbers?

- To enter characters as HEX numbers, you can enter HEX numbers with single quotes and a prefix of (X)
- Alternatively, just prefix HEX numbers with (Ox).

34. How would you get the current date in Mysql?

By using SELECT CURRENT_DATE(); 

35. Is the syntax correct? Explain the meaning of the syntax given below

$dbc = mysqli_connect('data.aliensabductedme.com', 'owen', 'aliensrool', 'aliendatabase');
Yes the syntax is correct and this query is getting used to connect the database with a PHP script. PHP uses three functions to communicate with MySQL database: The three functions are: mysqli_connect(), mysqli_query(), and mysqli_close(). 
mysqli_connect() and mysqli_query() are used to connect to mysql database and issue a query to the database. mysqli_query() is also used to retrieve the string or any other data from the database. Mysqli_close() is used to close a connection with the database. 

36. MySQL - Stored Procedures and Triggers

Stored Procedures: 

A set of SQL statements is called a stored procedure, which can be compiled and stored in the server. The purpose of stored procedures is that, reissuing the entire queries is avoided. The query is parsed only once, thus provides better performance and information passed between server and the client is very less. 

Triggers:

A trigger is fired when a particular event occurs. It is also a stored procedure. A stored procedure can be installed which triggers automatically every time a record is deleted or updated or inserted.

37. MySQLvs. Oracle.

  •  Unlike oracle, mysql data types can store invalid dates and don't support time zones. 
  •  Transactions are better supported in Oracle as compared to Mysql. ROLE feature is available in Oracle and not in MySQL in versions less than 5.0 
  •  Large Database size is supported more in Oracle in contrast to MySql. 
  •  Replication in oracle is two way while one way in mysql.

38. Primary Keys and Auto Increment Fields in MySQL

Primary key is used to uniquely identify a row in a table. Usually the primary key is an integer value that could be an auto incremented value. The primary key column can also be a combination of two columns.

The column that is identified for PRIMARY key is defined in the schema as:

PRIMARY KEY (employee_id)

When a column is set to ''Auto Increment'', its value is automatically incremented in a sequence when a new row is inserted.

39. Tell us something about Heap tables.

- HEAP tables are found in memory. 
- They are used for high speed storage on temporary basis.

Some of their characteristics are: 
- They do not allow BLOB or TEXT fields. 
- Only comparison operators like =, <,>, = >,=< , can be used with them. 
- AUTO_INCREMENT is not supported by HEAP tables
- Indexes should be NOT NULL

40. Transaction-Safe Table Types in MySQL.

Transaction-Safe tables allow the transaction to be compact. It should either complete the transaction or revert or roll back all changes. This property makes transaction-safe tables more safe compared to non transaction safe tables. When an update is performed and it fails, all changes are reverted. These tables can provide a better concurrency of tables.

41. What are ENUMs used for in MySQL?

ENUM is used to limit the possible values and store it together. It is a function that can be created to store the similar values together. It is used in creation of table. The syntax of it is as follows:
CREATE TABLE months (month ENUM ''January'', ''February'', ''March'','); 
INSERT months VALUES (''April'');

42. What are the advantages of MySQL in comparison to Oracle?

- MySQL is open source software available at zero cost. 
- It is portable 
- GUI with command prompt.
- Administration is supported by MySQL Query Browser

43. What are the applications required to support MYSQL?

The applications that are required to support MySQL are as follows:
1. php-mysql MySQL database is used specifically to support PHP
2. perl-DBI: provides generic Perl interface for interacting with relational databases
3. perl-DBD-MySQL MySQL database specific support for Perl
4. Web server is required to configure the database and its configuration
5. Programming language is required which supports MySQL.

44. What are the differences between MySQL_fetch_array(), MySQL_fetch_object(), MySQL_fetch_row()?

Mysql_fetch_object returns the result from the database as objects while mysql_fetch_array returns result as an array. This will allow access to the data by the field names. E.g. using mysql_fetch_object field can be accessed as $result->name and using mysql_fetch_array field can be accessed as $result->[name]. mysql_fetch_row($result):- where $result is the result resource returned from a successful query executed using the mysql_query() function.

Example:
$result = mysql_query(''SELECT * from students);
while($row = mysql_fetch_row($result))
{
Some statement;
}

45. What are the different tables present in MySQL?

There are many tables that remain present by default. But, MyISAM is the default database engine used in MySQL. There are five types of tables that are present:
1. MyISAM
2. Heap
3. Merge
4. INNO DB
5. ISAM

46. What are the disadvantages of MySQL?

 

  •  MySQL does not support a very large database size as efficiently 
  •  MySQL does not support ROLE, COMMIT, and Stored procedures in versions less  than 5.0 
  •  Transactions are not handled very efficiently. 

47. What are the limitations of mysql in Comparison of Oracle?

  •  Transactions are better supported in Oracle as compared to Mysql. ROLE feature  is available in Oracle and not in MySQL in versions less than 5.0 
  •  Large Database size is supported more in Oracle in contrast to MySql.

48. What are the Performance and Scalability characteristics of MySQL?

  MySQL has a unique storage engine architecture that makes it adaptable to most  servers. MySQL meets the expectations of the most common applications, i.e. to  run millions of transactions. Features like strong memory cache, indexing etc  adds to the performance. 

 MySQL being open source allows customization which allows users to add  their own requirements. MySQL also supports large number of embedded  applications. These features add to the scalability characteristic. 

49. What are the security recommendations while using MySQL?

 

  •  Access to the user table should never be given to avoid SQL injection attacks. 
  •  Privileges such as GRANT and REVOKE must be made use of. 
  •  SHOW GRANTS can be used to see the list of users who have access 
  •  Never run the MySQL server as the Unix root user 

50. What are the steps required to view your MYSQL database?

There are certain steps that are required to before you can view MySQL database and they are as follows:
1. Login as database user: for example: 
[root@ tmp]# mysql -u mysqluser -p sales
2. List all your MySQL databases: use the show command to view the list of all available MySQL databases. For example to view sales database use the command shown below:
mysql> show databases;
| Database |
| salesdata |

51. What areMyISAM tables?

  In MySQL MyISAM is the default storage engine. MyISAM tables store data values  with the low byte first. Even though MyISAM tables are very reliable, corrupted  tables can be expected if there is a hardware failure, the pc shuts down  unexpectedly. MyISAM tables are reliable because any change made to a table is  written before the sql statement returns. Even though MyISAM is the default  storage engine it is advisable to specify ENGINE= MYISAM 

52. What do you understand by MYSQL terminal?

MySQL terminal is used as a command line interface in many operating system. It provides a way to access the database and other resources using the SQL commands that are interpreted by the MySQL database server. 

53. What does myisamchk do?

- It compresses the MyISAM tables, which reduces their disk or memory usage.

How can we convert between Unix & MySQL timestamps?

- MySQL timestamp can be converted into Unix timestamp using the command UNIX_TIMESTAMP. 
- Unix timestamp can be converted into MySQL timestamp using the command FROM_UNIXTIME.

54. What does the file with the extension: frm, myd, and myi contain?

MySQL default table type is MyISAM, where there are three kind of files that are stored inside MyISAM. The file names begin with the table name and have the extensions such as frm, myd and myi. The explaination of each file is given below:
.frm file consists of the table definition that are stored in the database
.myd is an extension that is used by a data file.
.myi is an extension that is used by index file. 

55. What is a Trigger in MySQL? Define different types of Trigger

A trigger in MySQL is a database object that is associated with a table. A trigger is fired, when a particular event occurs for the table. Triggers are used to perform validation checks on data values for insertion or to perform calculations on values for updatation. 

They are 2 types of triggers - Before Trigger and After Trigger. Before Trigger fires before the execution of INSERT, DELETE and UPDATE commands. After trigger fires after the execution of INSERT, DELETE and UPDATE commands.

56. What is BLOB?

- BLOB stands for binary large object. 
- It that can hold a variable amount of data. 

There are four types of BLOB based on the maximum length of values they can hold:

- TINYBLOB
- BLOB
- MEDIUMBLOB 
- LONGBLOB

57. What is difference between mysql_connect and mysql_pconnect?

Mysql_connect() opens a new connection to the database while mysql_pconnect() opens a persistent connection to the database. This means that each time the page is loaded mysql_pconnect() does not open the database. Mysql_close() cannot be used to close the persistent connection. Though it can be used to close mysql_connect().

58. What is HEAP table?

  Tables that are present in the memory are called as HEAP tables. When creating a HEAP table in MySql, user needs to specify the TYPE as HEAP. These tables are now more commonly known as memory tables. These memory tables never have values with data type like ''BLOB'' or ''TEXT''. They use indexes which make them faster. 

59. What is MySQL data directory? How to determine the location of the data directory?

MySQL stores its data on the disk on the data dictionary. Each subdirectory under this data dictionary represents a MySQL database, inside those directories. By default the information managed my MySQL = server mysqld is stored in data directory.A default location of data directory in windows is C:\mysql\data or C:\Program Files\MySQL\MySQL Server 5.0 \data.. 

60. What is Query Cache in MySQL?

  Query Cache in MySQL is used in scenarios when the same queries need to be executed on the same data set. These queries also return the same result. Query cache is most useful when there are tables that are not expected to change very often. It is important to note that the query cache does not return old data. If the tables are modified, any important entries in the query cache are flushed. 

61. What is required to create MYSQL database?

To create MySQL databse the first component which has to be present is a database server on which the queries of database will run and software tool through which you can access the applications. It also requires PHP scripts for communicating with the database using SQL commands. 

62. What is TEXT?

TEXT is case-insensitive BLOB. The four types of TEXT are: 

- TINYTEXT
- TEXT
- MEDIUMTEXT
- LONGTEXT

63. What is the difference between a database and a table?

There is a major difference between a database and a table. The differences are as follows:
Tables are a way to represent the division of data in a database. Whereas, database is a collection of tables and data
Tables group the data in relation with each other and create a dataset; this dataset will be used in the database. The data which are stored in the table in any form is a part of the database, but opposite is not true. 

64. What is the difference between BLOB and TEXT?

- In BLOB sorting and comparison is performed in case-sensitive for BLOB values 
- In TEXT types sorting and comparison is performed case-insensitive.

65. What is the difference between CHAR_LENGTH and LENGTH in MySQL?

CHAR_LENGTH, as the name suggests, returns the number of characters / character count. The LENGTH returns the number of bytes / bytes count. To count the Latin characters, both lengths are the same. To count Unicode and other encodings, the lengths are different.

66. What is the difference between MYSQL and SQL?

SQL is known as standard query language, as the name implies it is the language which is used to interact with the database like MySQL. Whereas, MySQL is a database that store various types of data and keep it safe. A PHP script is required to store and retrieve the values inside the database. 

67. What is the difference between truncate and delete?

Delete command is used to delete data from a table for example Remove emails where we write a script to delete the customer's data. It deletes the rows of data from a table. The syntax of it as follows:
DELETE FROM table_name
Whereas, truncate is very dangerous command and should be used carefully as it deletes every row from a table. The syntax of it as follows:
TRUNCATE TABLE "table_name"

68. What is the difference between Unix timestamps and MySQL timestamps?

The unix timestamp is stored as 32 bit integer whereas, MySQL timestamps are stored in 32 bit integers but represented differently then UNIX timestamps like YYYY-MM-DD HH:MM:SS format. Unix timestamp is given as month-day-year-HH:MM:SS..

69. What is the procedure to configure the application of MYSQL?

The procedure to configure the application of MySQL is:
1. First create a database
2. Test the database by informing about the database name, IP address of database client server, username and password of application. 
3. Edit the special application specific configuration file using a GUI or command line. 
4. Configure the language with which MySQL will interact.

70. What is the purpose of -> in the MySQL terminal?

-> prompt in the command of MySQL indicates that a single statement is being entered across multiple lines. From this prompt MySQL interprets that you haven't finished entering the statements. It has no impact of enter which you might press to go to the next line. MySQL will execute the statement only when you will insert the semicolon in the end which it recognizes.

71. What is the use of i-am-a-dummy flag in MySQL?

Using the i-am-dummy flag makes the SQL engine refuse any Updates or deletes to execute if the WHERE clause is not present. It is very useful when using delete statements. Using i-am-dummy flag will not allow the following statement to execute:

Delete from employee;

72. What you can use Regular Expression for in MySQL? Support your answer with an example.

Regular expressions in MySql are used in queries for searching a pattern in a string.

  •  * Matches 0 more instances of the string preceding it. 
  •  + matches 1 more instances of the string preceding it. 
  •  ? Matches 0 or 1instances of the string preceding it. 
  •  . Matches a single character. 
  •  [abc] matches a or b or z 
  •  | separates strings 
  •  ^ anchors the match from the start.
  

REGEXP can be used to match the input characters with the database.

Example:

The following statement retrieves all rows where column employee_name contains the text 1000 (example salary):

Select employee_name
From employee 
Where employee_name REGEXP '1000'
Order by employee_name

 ''.'' Can be used to match any single character. ''|'' can be used to match either of the two strings 

73. When to use ORDER BY in DELETE statement?

The ORDER BY clause in DELETE statement is used when a deletion has to take place by in a specified order. The syntax is like this 
DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count] 
ORDER BY clause is specified, the rows are deleted in the order that is specified.

74. Where's database data actually stored? Is there a way to see the files which are stored?

Database data is usually get stored in the computer hard-disk and you can manage the data by the database program like MySQL and phpAdmin. The files can be seen but database files remain in binary format so it can be opened and read but, you have to put extra effort to understand it. SQL is given for the purpose of interacting with the database and read the database and retrieve the information out of it.

75. Why phpMyAdmin is used for MYSQL?

PhpMyAdmin is a very popular and easy to use GUI tool that can allow SQL commands to be run to create database, create tables, insert data and retrieve it. It provides a web based interface to the user for the ease of use. phpMyAdmin allows user to manage everything from one place and no other installation is required in the computer after this. 

76. Why to use CHAR instead of VARCHAR in the database?

CHAR is much more accurate and efficient to use. CHAR doesn't have to keep a count of the variable length. It is more efficient when you have to use it for a text column which is of an exact length. Char is used for the data which are fixed, but VARCHAR is used for data like password, which are variable.

77. Write a command to view MySQL database table structure

To view the database table structure describe command is used that provides the list of all the data fields used in the database table. Example: a table named sales will have the four fields like: name, description, num, and date.
mysql> describe test;
| Field | Type | Null | Key | Default | Extra|
| num | int(11)| |PRI | NULL | auto_increment |
| date | date| | MUL | 0000-00-00 | 
| name | varchar(50) | MUL |
| description | varchar(75) | YES | | NULL

78. Write a command to view the content of the table

To view all the data that is contained inside a table named sales use the select command. For example: to see the data of first row in a table using the command as:
mysql> select * from sales limit 1;
If the database is created recently then it will give a blank listing, but after the data is being entered it will show the full listing in a tabular form.

79. Write a command with which MySQL table can be repaired

The command syntax with which mysql table can be repaired is as follows:
REPAIR TABLE tablename;
REPAIR TABLE tablename QUICK;
REPAIR TABLE tablename EXTENDED;
The command will just do as it says repair a specified table, but if QUICK or EXTENDED is used then the meaning of it changes. In case of QUICK it will repair only the index tree, whereas in case of EXTENDED it will create index row by row and repair it. 

80. Write a query to create a database and a table?

MySQL comes up with some default database that can be used as a base to create a new one. The command that is used to create a new database is as follows:
CREATE DATABASE SQL command
The command has to be written in MySQL terminal. This command will create a new database and then you can create new tables and include data in it.

81. Write a query to MYSQL in safe mode and to change the root password

To start MySQL in safe mode, mysqld_safe command is used which allow it to run in the safe mode and it also doesn't allow the reading of tables with the database passwords:
[root@ ]# mysqld_safe --skip-grant-tables --skip-networking &[1] 13007
[root@ ]# Starting mysqld daemon with databases from /var/lib/mysql
[root@ ]#
After running the MySQL in safe mode the password protection gets removed and to use the password protection mechanism a command is used as follows: 
mysql -u root command
[root@bigboy tmp]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.16
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> [ a message is being shown which allow user to take the control of the root]

82. Write a query to stop MYSQL in unix

The query to stop MySQL is quite useful when an error is occurred or when data has to be saved from any mishap. It is also used for retrieving the root password because it is either easily forgotten or misplaced. To stop the service the following command is required: 
1) Stop MySQL
[root@ tmp]# service mysqld stop
Stopping MySQL: [ OK ]
[root@ tmp]#