Set - 5

Question 6 :

Give the syntax of GRANT commands?

Answer :

The generic syntax for GRANT is as following

GRANT [rights] on [database] TO [username@hostname] IDENTIFIED BY [password]

Now rights can be:
a) ALL privilages
b) Combination of CREATE, DROP, SELECT, INSERT, UPDATE and DELETE etc.

We can grant rights on all databse by usingh *.* or some specific database by database.* or a specific table by database.table_name.


Question 7 :

Give the syntax of REVOKE commands?

Answer :

The generic syntax for revoke is as following

REVOKE [rights] on [database] FROM [username@hostname]

Now rights can be:
a) ALL privileges
b) Combination of CREATE, DROP, SELECT, INSERT, UPDATE and DELETE etc.

We can grant rights on all database by using *.* or some specific database by database.* or a specific table by database.table_name.


Question 8 :

What is the difference between CHAR and VARCHAR data types? 

Answer :

CHAR is a fixed length data type. CHAR(n) will take n characters of storage even if you enter less than n characters to that column. For example, "Hello!" will be stored as "Hello! " in CHAR(10) column. 

VARCHAR is a variable length data type. VARCHAR(n) will take only the required storage for the actual number of characters entered to that column. For example, "Hello!" will be stored as "Hello!" in VARCHAR(10) column.


Question 9 :

How can we encrypt and decrypt a data present in a mysql table using mysql?

Answer :

AES_ENCRYPT() and AES_DECRYPT()


Question 10 :

Will comparison of string "10" and integer 11 work in PHP?

Answer :

Yes, internally PHP will cast everything to the integer type, so numbers 10 and 11 will be compared.