Online Book Reader

Home Category

MySQL in a Nutshell [49]

By Root 22541 0
the C-language crypt function. A two-character string may be given in the second argument to increase the randomness of encryption. The resulting string cannot be decrypted. You should not use this function for the password column in the user table of the mysql database. Use PASSWORD⁠(⁠ ⁠ ⁠) instead. Here is an example:

UPDATE teachers

SET pwd = ENCRYPT('test', 'JT')

WHERE teacher_id = '730522';

Name

MD5⁠(⁠ ⁠ ⁠)

Synopsis

MD5(string)

This function uses a Message-Digest algorithm 5 (MD5) 128-bit checksum to return a 32-character hash value of string from the Request for Comments (RFC) 1321 standard. Here is an example:

SELECT MD5('Test') AS 'MD5( ) Test';

+----------------------------------+

| MD5( ) Test |

+----------------------------------+

| 0cbc6611f5540bd0809a388dc95a615b |

+----------------------------------+

Name

OLD_PASSWORD⁠(⁠ ⁠ ⁠)

Synopsis

OLD_PASSWORD(string)

This function encrypts a given string based on the password encryption method used prior to version 4.1 of MySQL. The result cannot be decrypted. Here is an example:

UPDATE teachers

SET pwd = OLD_PASSWORD('test')

WHERE teacher_id = '730522';

Name

PASSWORD⁠(⁠ ⁠ ⁠)

Synopsis

PASSWORD(string)

This function encrypts a password given as an argument. The result cannot be decrypted. This function is used for encrypting data in the password column of the user table in the mysql database. Here is an example:

UPDATE teachers

SET pwd = PASSWORD('test')

WHERE teacher_id = '730522';

Name

SESSION_USER⁠(⁠ ⁠ ⁠)

Synopsis

SESSION_USER⁠(⁠ ⁠ ⁠)

This function returns the username and the hostname for the current MySQL connection. The function takes no arguments. It’s synonymous with SYSTEM_USER⁠(⁠ ⁠ ⁠) and USER⁠(⁠ ⁠ ⁠).

Name

SHA⁠(⁠ ⁠ ⁠)

Synopsis

SHA(string)

This function returns the Secure Hash Algorithm (SHA) 160-bit checksum for the given string. The result is a string composed of 40 hexadecimal digits. NULL is returned if the given string is NULL. This function is synonymous with SHA1⁠(⁠ ⁠ ⁠). Here is an example:

SELECT SHA('test');

+------------------------------------------+

| SHA('test') |

+------------------------------------------+

| a94a8fe5ccb19ba61c4c0873d391e987982fbbd3 |

+------------------------------------------+

Name

SHA1⁠(⁠ ⁠ ⁠)

Synopsis

SHA(string)

This function returns the SHA 160-bit checksum for the given string. The result is a string composed of 40 hexadecimal digits. NULL is returned if the given string is NULL. This function is synonymous with SHA⁠(⁠ ⁠ ⁠).

Name

SYSTEM_USER⁠(⁠ ⁠ ⁠)

Synopsis

SYSTEM_USER⁠(⁠ ⁠ ⁠)

This function returns the username and the hostname for the current MySQL connection. The function takes no arguments. It’s synonymous with SESSION_USER⁠(⁠ ⁠ ⁠) and USER⁠(⁠ ⁠ ⁠).

Name

USER⁠(⁠ ⁠ ⁠)

Synopsis

USER⁠(⁠ ⁠ ⁠)

This function returns the username and the hostname for the current MySQL connection. The function takes no arguments. It’s synonymous with SESSION_USER⁠(⁠ ⁠ ⁠) and withSYSTEM_USER⁠(⁠ ⁠ ⁠). Here is an example:

SELECT USER( );

+-------------------+

| USER( ) |

+-------------------+

| russell@localhost |

+-------------------+

Chapter 5. Database and Table Schema Statements

This chapter explains the SQL statements in MySQL related to database and table schema. These statements create, alter, and delete databases and tables, as well as display information related to databases, tables, and columns. The statements in this chapter pertain to information about these data structures, not the manipulation of data within them; statements that affect the data are covered in the next chapter. In essence, this chapter covers the SQL statements used when one is in the mode of creating database structures. This mode is a fairly distinct mindset and is sometimes the responsibility of different persons from those who manipulate the data itself.

This chapter covers the following SQL statements:

ALTER DATABASE, ALTER SCHEMA, ALTER SERVER, ALTER TABLE, ALTER VIEW, CREATE DATABASE, CREATE INDEX, CREATE SCHEMA, CREATE SERVER, CREATE TABLE, CREATE

Return Main Page Previous Page Next Page

®Online Book Reader