����������
WEB - ������

www.spravkaweb.ru Rambler's Top100
 ï¿½ï¿½ ����������: �������/MySQL/�������� � �������� �������.Ðàñïå÷àòàòü 
�������
�������
����� ���
HTML
JavaScript
VBScript
CSS
Flash
Perl
PHP
MySQL
SSI
VRML
�������������
������
�����
��������
������
�������� ���
�����:
��������
Subscribe.Ru:

MySQL

<--����� | ��������� � ������ | ������-->
�������� � �������� �������
�������� ������� ������������ �������� CRTEATE TABLE.
CREATE TABLE table_name(column_name1 type, column_name2 type,...)
  • table_name - ��� ����� �������;
  • column_name - ����� ������� (�����), ������� ����� �������������� � ����������� �������.
  • type - ���������� ��� ����������� �������.
    ���� ������, ������������ ��������� type
    ����� �����
    ����� ��� �������� ���� ������:
    �������INT [UNSIGNED]
    �������������� ���� UNSIGNED ������, ��� ����� ������� ���� ��� �������� ����������� ����� (������� ��� ������ 0).
    TINYINT����� ������� ����� �� -128 �� 127
    SMALLINT�������� �� -32 768 �� 32 767
    MEDIUMINT�������� �� -8 388 608 �� 8 388 607
    INT�������� �� -2 147 483 648 �� 2 147 483 647
    BIGINT�������� �� -9 223 372 036 854 775 808 ��
    9 223 372 036 854 775 807
     
    ������� �����
    ����� ��� ��, ��� ����� ����� �������������� � MySQL �� ��������� ��������������, MySQL ������������ � ��������� ����� ������� �����.
    � ����� ���� ��� ������������ ���:
    �������[(length, decimals)] [UNSIGNED]
    ����� length - ���������� ��������� (������ ����), � ������� ����� ��������� ������� ����� ��� ��� ��������.
    decimals - ���������� ������ ����� ���������� �����, ������� ����� �����������.
    UNSIGNED - ������ ����������� �����.
    FLOAT����� � ��������� ������ ��������� ��������.
    DOUBLE����� � ��������� ������ ������� ��������.
    REAL������� ��� DOUBLE.
    DECIMAL������� �����, ���������� � ���� ������.
    NUMERIC������� ��� DECIMAL.
     
    ������
    ������ ������������ ����� ������� ��������. ������ ��� ������ �� ��������� ����� �� ������� SELECT �� ������� � ������������ ������� ��������, �.�. ������ "����" � "����" ��������� �����������. ����� ����, ���� ���� ������ ��������� �� �������������� ������������� ������ ��� ��� ��������� � ����������, ��� ���� ����� ��������� � ��������� ���� ���������.

    ��� ������ ����������� � ����� ������, ������� ����� ������� �� ����� length ��������, ��� length ����������� ��������� �� 1 �� 255.
    VARCHAR (length) [BINARY]

    ��� ��������� ���������� �������� � ���� ������ ���� �� ���� ������������� ���������� �������� �������. ���� ������ ���� BINARY, �� ��� ������� SELECT ������ ����� ������������ � ������ ��������.
    VARCHAR����� ������� �� ����� 255 ��������.
    TINYTEXT����� ������� �� ����� 255 ��������.
    TEXT����� ������� �� ����� 65 535 ��������.
    MEDIUMTEXT����� ������� �� ����� 16 777 215 ��������.
    LONGTEXT����� ������� �� ����� 4 294 967 295 ��������.
    ���� ����� ����������� ��� TEXT, �� ���� �� �� �������, ��� ������ �� ����� ��������� 65 536 ��������, ����������� LONGTEXT.
     
    �������� ������
    �������� ������ - ��� ����� �� �� �����, ��� � ������ � ������� TEXT, �� ������ ��� ������ � ��� ����������� ������� ��������.
    TINYBLOB����� ������� �� ����� 255 ��������.
    BLOB����� ������� �� ����� 65 535 ��������.
    MEDIUMBLOB����� ������� �� ����� 16 777 215 ��������.
    LONGBLOB����� ������� �� ����� 4 294 967 295 ��������.
    BLOD-������ �� �������������� �������������, ���� ��� ������ � ������������� ����������� �������� ����������� ��������������� ������ "�� ����".
     
    ���� � �����
    MySQL ������������ ��������� ����� �����, ���������� ��������������� ��� �������� ��� � ������� � ��������� ��������.
    DATE���� � ������� ����-��-��
    TIME����� � ������� ��:��:��
    DATETIME���� � ����� � ������� ����-��-�� ��:��:��
    TIMESTAMP���� � ����� � ������� timestamp. ������ ��� ��������� �������� ���� ��� ������������ �� � ������� timestamp, � � ���� ��������������, ��� ������ ������� ������������ ��� ������������� � PHP


    ��������, ��� ���� ������� ������� ���������� ������� ������.
    ���� ������� ����� �������� �� ���� ��������: ��� �����, ����� � �������
    CREATE TABLE tel_numb(fio text, address text, tel text)
    
    �� PHP ��� ����� ��������� ��������� �������:
    $sql="CREATE TABLE tel_numb(fio text, address text, tel text)";
    mysql_query($sql);
    
    � ���� ������ ����� ������������ ������������, ������� ������ ��� "���������" � �� ��������, ������� ����� (���, ��������, ���������) ��������� � ��������������� ���������.
    not null - ��������, ��� ���� �� ����� ��������� �������������� ��������, �.�. ���� ����������� ������ ���� ���������������� ��� ������� ����� ������ � ������� (���� �� ������ �������� �� ���������).
    ��������, ��� ����� ������� � ���������� ����� �������, ��� ���� � ��� ����� (���� fio) � ��� ��������� (���� tel) �� ����� ����� ��������������� ��������:
    CREATE TABLE tel_numb(fio text NOT NULL, address text, tel text NOT NULL)
    
    primary key - ��������, ��� ���� �������� ��������� ������, �.�. ��������������� ������, �� ������� ����� ���������.
    CREATE TABLE tel_numb(fio text, address text, tel text, PRIMARY KEY (fio))
    
    auto_increment - ��� ������� ����� ������ ���� ������� ���������� ��������, ��� ��� � ������� ������� �� ����� ������������ ��� ���� � ����������� ��������.
    CREATE TABLE tel_numb(fio text AUTO_INCREMENT, address text, tel text)
    
    default - ������ �������� �� ��������� ��� ����, ������� ����� ������������, ���� ��� ������� ������ ��� ����� ���� ������ ���� ������� ��������.
    CREATE TABLE tel_numb(fio text, address text DEFAULT '�� ������', tel text)
    


    �������� ������� ������������ �������� DROP TABLE
    DROP TABLE table_name
  • table_name - ��� ��������� �������.
    DROP TABLE tel_numb
    
    �� PHP ��� ����� ��������� ��������� �������:
    $sql="DROP TABLE tel_numb";
    mysql_query($sql);
    
  • �����������




    ���:
    ����:
    ����������:
    ������ / � ����������
     
    ��� ������:
    05.04.2004
    ��������� ����������� ���� �������� ����� � �����.
    ������, ����� � ������������ ������ ���� ��������? � ����� flash-����� ��� ����?
    ��� ��� ������� ������� � ������ ��� �������� � ������ ��������.
    �����������:
    ���� ������ � �����:
    ������ �����!
    ����������.
    ��� ����.
    ��� ��� �����.
    ������.
    ���� �� �����!
    ��������:
    Rambler's Top100
    Ñäåëàòü ñòðàíèöó ñòàðòîâîé ������� �������� ���������
    Äîáàâèòü ñòðàíèöó â èçáðàííîå �������� ���� � ���������
    Ñîîáùèòü îá íàéäåííîé îøèáêå �������� �� ������