lamp_training_session_6
DESCRIPTION
Presentaions of LAMP Training Conducted by T.Umapathi Anand and R.Kasturi from Southern Telecom Region, BSNL at RTTC Trivandrum.TRANSCRIPT
����������
������������� ���� ������������� ���� ������� ��� �� ��� �
����������
������������
�� ��� � �������������� �����
�� ������� ����� �������� �!����������������
��� ���� � ���������� ����� ������������""����������� � #��������� �$�������������
��� �����������%���&
����''������� ���� ������������� ���� ������� ��� �� ��� �
��� �����������%���&
���� ����� � �������������������� ����� ��������� ��� ��( ���������� ������� ��������%����� �
� �������������������%�( �������%��&
It is a RDBMS Developed, Distributed and Supported by MySQL AB
It is Open Source
It is Fast, Reliable and Easy to Use
������������
����))������� ���� ������������� ���� ������� ��� �� ��� �
It can work as Client/Server or as Embedded System.
Written in C and C++
Works on Many Platforms
It can Handle Multiple CPUs effectively if available
Provides Transactional and Non Transactional Storage Engines
Very fast Thread based Memory Allocation System
���� ������ ��
����**������� ���� ������������� ���� ������� ��� �� ��� �
Very fast Thread based Memory Allocation System
Supports In Memory Hash Tables
Tested with Purify and Valgrind for best performance
Handles Huge Databases
Portable Code
� ��� �� ��� � ����++������� ���� ������������� ���� ������
������ ����� � ��� � ��� �
����������� ���������Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 6Server version: 6.0.3-alpha-community MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
��������������
������������� ���� ������������� ���� ������� ��� �� ��� �
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
�������
������ ��������������+--------------------+| Database |+--------------------+| information_schema || dbone || mysql || test |+--------------------+
������������������
����,,������� ���� ������������� ���� ������� ��� �� ��� �
+--------------------+4 rows in set (0.00 sec)
����������������Database changed
������
����������������� ��� �����+----+---------+--------+| id | name | color |+----+---------+--------+| 1 | apple | red || 2 | cherry | red || 3 | banana | yellow || 7 | grape | black || 8 | mango | yellow |
������
����--������� ���� ������������� ���� ������� ��� �� ��� �
| 8 | mango | yellow || 6 | goa | green || 9 | suppota | brown || 10 | jack | green |+----+---------+--------+8 rows in set (0.00 sec)
������
������ ���� ����� �����+-------+-------------+------+-----+---------+----------------+| Field | Type | Null | Key | Default | Extra |+-------+-------------+------+-----+---------+----------------+| id | int(5) | NO | PRI | NULL | auto_increment || name | varchar(25) | YES | | NULL | || color | varchar(15) | YES | | NULL | |+-------+-------------+------+-----+---------+----------------+3 rows in set (0.00 sec)
������������
����..������� ���� ������������� ���� ������� ��� �� ��� �
3 rows in set (0.00 sec)
������
��������������������� � ��� ����� �� ���������+---------+--------+| name | color |+---------+--------+| apple | red || banana | yellow || cherry | red || goa | green || grape | black |
������
�����/�/������� ���� ������������� ���� ������� ��� �� ��� �
| grape | black || jack | green || mango | yellow || suppota | brown |+---------+--------+8 rows in set (0.00 sec)
������
����������������� � � ���� ��� � �� �� ����+----+--------+-------+| id | name | color |+----+--------+-------+| 1 | apple | red || 2 | cherry | red |+----+--------+-------+2 rows in set (0.00 sec)
����������������� � � ���� ��� � �� �� ���� �� ���������
������
��������������� ���� ������������� ���� ������� ��� �� ��� �
����������������� � � ���� ��� � �� �� ���� �� ���������+----+--------+--------+| id | name | color |+----+--------+--------+| 1 | apple | red || 2 | cherry | red || 3 | banana | yellow || 8 | mango | yellow |+----+--------+--------+4 rows in set (0.00 sec)
� ��� �� ��� � �����'�'������� ���� ������������� ���� ������
��������������������
0$� 0$� �� ������ ����
������������ �� � � � ��������� � �� �����������
� ��� ��� ��� ��� ��� ��� ��� �� �����������������
��� � �� ���� � �� ���� � �� ���� � �� � �� � � �
�� � � �� � � ���� � ���
����� ��������������������������������
���������������������
�����)�)������� ���� ������������� ���� ������� ��� �� ��� �
�� � � �� � � ���� � ������������������������
�� ��� ��� ��� ��� ��� ��� ��� � �� � � �
�� � � �� � � ���� � ���
������ ������������������������ ���!��� �����
��������������������� �
� � �� � �� �� � �� � �� �� � �� � �� �� � �� � �� � �� � � �
�� � � �� � � ���� � ���
����� ������������������������! !!��!���! !!����
������������������������
�� ��� ��� ��� � �� � � �
�� � � �� � � ���� � ���
����� ������������������������� � ! � ����� � ! � !
������������������ �" "���"�
��������������������
0$� 0$� �� ������ ����
��� �� ���� �� ���� �� ���� �� � �� � � �
�� � � �� � � ���� � ���
!����� �������
� ���� ���� ���� ����� � �� � �
�� � � �� � � ���� � ���
�������#��$���� ��������#����% �& ���' ��( ������������(�$�& ���)���
( ���( ������*�����(�$�& ���)����+' �,��-
� � � �� � � �� � � �� � � ��� � �� � � (�����#��$���� ��������#����% �& ���
�����*�*������� ���� ������������� ���� ������� ��� �� ��� �
� � � �� � � �� � � �� � � ��� � �� � �
�� � � �� � � ���� � ���
(�����#��$���� ��������#����% �& ���' ��( ������������(�$�& ���)���
( ���( ������*�����(�$�& ���)����+' �,��-
� �� �� �� � �����& ����(. ��/0
� � �� ��� � �� ��� � �� ��� � �� ���� � �� � �
�� � � �� � � ���� � ���
(�����#��$���� ��������#����% �& ���' ��( ������������(�$�& ���)����+' �,���-
( ���( ������*�����(�$�& ���)����+' �,� �-
��� � ��� � � � �� ��� ���� � ��� � � � �� ��� ���� � ��� � � � �� ��� ���� � ��� � � � �� ��� � �����& ����(01�' */
��������������������
0$� 0$� �� ������ ����
� �� � �� � �� � �� 2222�' ' �((���������""""���
� �� ��� � �� ��� � �� ��� � �� ��� 2222�' ' �(( �334' ' 4�����������4��4�����""""��� �� 4�"4�"
��� ���� ���� ���� ���� ���� ���� ���� � ���,���& �����& )
334' ' 4��
�����+�+������� ���� ������������� ���� ������� ��� �� ��� �
��� ��� ��� ��� 334' ' 4��
� �� �� ��� �� �� ��� �� �� ��� �� �� ��
� �� �� ��� �� �� ��� �� �� ��� �� �� ��
"��������"
"�������
��� �� ���� � � ���� �� ���� � � ���� �� ���� � � ���� �� ���� � � � ����������������/������'
��� ��� �� ���� � � ���� ��� �� ���� � � ���� ��� �� ���� � � ���� ��� �� ���� � � � 5������������������������/������'
� � �� ��� � � �� � �� ��� � � �� � �� ��� � � �� � �� ��� � � � ���������/������'
��� � � �� ��� � � ���� � � �� ��� � � ���� � � �� ��� � � ���� � � �� ��� � � � 5�����������������/������'
��������������������
0$� 0$� �� ������ ����
��� �� ���� � � ���� �� ���� � � ���� �� ���� � � ���� �� ���� � � � �! �������������(����
� ���� � � �� ���� � � �� ���� � � �� ���� � � � �� �������������(����
� � �� � � ���� � � �� � �� � � ���� � � �� � �� � � ���� � � �� � �� � � ���� � � � �� �������������(����
� � � ���� � � � � � � ���� � � � � � � ���� � � � � � � ���� � � � � � �������������(����
��� �� ����� � � ���� �� ����� � � ���� �� ����� � � ���� �� ����� � � � �! ��������,��(���
��������������� ���� ������������� ���� ������� ��� �� ��� �
��� �� ����� � � ���� �� ����� � � ���� �� ����� � � ���� �� ����� � � � �! ��������,��(���
� ����� � � �� ����� � � �� ����� � � �� ����� � � � �� ��������,��(����
� � �� � � ����� � � �� � �� � � ����� � � �� � �� � � ����� � � �� � �� � � ����� � � � �� ��������,��(����
� � � ����� � � � � � � ����� � � � � � � ����� � � � � � � ����� � � � � � ��������,��(����
� � � � ������� �! � � � � � ������� �! � � � � � ������� �! � � � � � ������� �! � 0��& ������6�' �,���� ��7�����
� �� ������� �! �� �� ������� �! �� �� ������� �! �� �� ������� �! � /������5�����6�' �,�� �7�����
� ��� �� ��� � �����,�,������� ���� ������������� ���� ������
���������� ������������ ��
�"#$%&�"#$%&�"#$%&�"#$%&�"#$%&�"#$%&�"#$%&�"#$%&
���������������
����� ��������������
'()*+ '()*+ '()*+ '()*+ '()*+ '()*+ '()*+ '()*+ � ,)#)("+#'� ,)#)("+#'� ,)#)("+#'� ,)#)("+#'� ,)#)("+#'� ,)#)("+#'� ,)#)("+#'� ,)#)("+#'
�� ������������
� ����������������������
�����-�-������� ���� ������������� ���� ������� ��� �� ��� �
� ����������������������
�� !��"������������������#
�" $�%&�'�%�
�� ��( �����������)�
� �������*����������)�
� ��"
�+ ������,������-.
�� $�%&���������������� -
�/ 0�%�������/�
�1 ��2��%����1�
��������������������
������ )3)45�6-75��
8��� )-9)-5�6�-��-9.4� �:)�5��9)3�-
;�<�2�%�=�� <>#!3 7�7)#��������� ?@�A��<��:� ���� )#;BC�.#-�.������������� 8��B
$������ ��������������������������� )8���� ���� �
�����.�.������� ���� ������������� ���� ������� ��� �� ��� �
$� "�))) �:����������������� 3$���)3������������������� )���)
����
����������������������������
� -. . +%"'� -. . +%"'� -. . +%"'� -. . +%"'� -. . +%"'� -. . +%"'� -. . +%"'� -. . +%"'
D *����E����������E� ���D����F=��2
66 *����E����������E� ���66 ���F=��2
GH�����HG ����0���� "�(����GH���2�HG����F=��2
����'/'/������� ���� ������������� ���� ������� ��� �� ��� �
� ��� �� ��� � ����'�'�������� ���� ������������� ���� ������
�#$",. +"$(�#$",. +"$(�#$",. +"$(�#$",. +"$(�#$",. +"$(�#$",. +"$(�#$",. +"$(�#$",. +"$( *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#'
. )�����. )����� (��$��)���(��$��)���
//// *�������. )�����
0000 ������$����. )�����
1111 ' ����)��$�����. )�����
2222 (�7�����. )�����
� ��� �� ��� � ����''''������� ���� ������������� ���� ������
2222 (�7�����. )�����
3333 ' ����. )�����
�$"4 $'+�$"4 $'+�$"4 $'+�$"4 $'+�$"4 $'+�$"4 $'+�$"4 $'+�$"4 $'+ *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#'
. )�����. )����� (��$��)���(��$��)���
5555 *%(�. )�����
6666 . 8�. )�����
7777 ��7��������
8888 9. 8�. )�����
� ��� �� ��� � ����')')������� ���� ������������� ���� ������
8888 9. 8�. )�����
99999999 8�����������. )�����
::�::�::�::� /����������. )�����
-&$();-&$();-&$();-&$();-&$();-&$();-&$();-&$(); *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#'
. )�����. )����� (��$��)���(��$��)���
55���� �55���� �55���� �55���� � *%(�. )�����
66�� �66�� �66�� �66�� � . 8�. )�����
<<<< 0:����. )�����
9999 ;�����������
� ��� �� ��� � ����'*'*������� ���� ������������� ���� ������
9999 ;�����������
:::: /��������
9<9<9<9< ;��������������0:�����
:<:<:<:< /�����������0:�����
=<��:9�=<��:9�=<��:9�=<��:9� %��0:����. )�����
:<9:<9:<9:<9 %�//������. )�����
� �� �� �� � 9. 8�. )�����
",+# ",+# ",+# ",+# ",+# ",+# ",+# ",+# *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#'
. )�����. )����� (��$��)���(��$��)���
� �> � �! ��� � �!� �> � �! ��� � �!� �> � �! ��� � �!� �> � �! ��� � �! 1��$<�����7��������������������
��� �� ���� �� ���� �� ���� �� � 1����������������������������
� �� �� �� �� �� �� �� � 1����. )�����
� ��� ��� ��� �� (�7�����. )�����
� ��� �� ��� � ����'+'+������� ���� ������������� ���� ������
� ��� ��� ��� �� (�7�����. )�����
���� ��� � ���� ��� � ���� ��� � ���� ��� � %��% �//�5���������
���� ����� ����� ����� � �������7��������������������
���� � ���� � ���� � ���� � %�//�5���������
�������� �������5������������������
�? �? �? �? ��& )���#�������' ��$����
� �� �� �� � � �> � �! ��� �� �> � �! ��� �� �> � �! ��� �� �> � �! ��� � 1��$<�����7��������������8����
",+# ",+# ",+# ",+# ",+# ",+# ",+# ",+# *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#' *+#)"-#'
. )�����. )����� (��$��)���(��$��)���
� �� �� �� � �? �? �? �? %�����������& )���#�������' ��$����
� ��� � ��� ��� � ��� ��� � ��� ��� � �� %���������8�������0,)������
� ���=� ���=� ���=� ���= %�����7��5����
� � ��� � ��� � ��� � �� #�������& ��$��������8�������0,)������
� ��� �� ��� � ����'�'�������� ���� ������������� ���� ������
� � ��� � ��� � ��� � �� #�������& ��$��������8�������0,)������
� �? � �? � �? � �? 80;09#
� � � � ���? � � � � ���? � � � � ���? � � � � ���? 1& )���������
� ��� �� ��� � ����',',������� ���� ������������� ���� ������
ABS(x)ABS(x)..& ��:�=�����! ����1'23
�=��
& ��:�=�����! ����1�+'23
�=���
CEIL(x)CEIL(x)& ��:�=�����! �!���1�&'+23
� ������������� �������� ������������� �������
� ��� �� ��� � ����'-'-������� ���� ������������� ���� ������
& ��:�=�����! �!���1�&'+23
�=��
& ��:�=�����! �!���1��&'+23
�=��
CONV(CONV(N,from_base,to_baseN,from_base,to_base))& ��:�=�����! �!4 5 617�8#��#'23
�=�>��?
& ��:�=�����! �!4 5 617��8#�-#-23
�=�>��?
MOD(N,M)MOD(N,M)..& ��:�=�����! �� 4 �1)'#,23
�=�
& ��:�=�����! �� 4 �1)/&'#*23
�=��6�
FLOOR(x)FLOOR(x)& ��:�=�����! �9�4 4 �1�&'+23
� ������������� �������� ������������� �������
� ��� �� ��� � ����'.'.������� ���� ������������� ���� ������
& ��:�=�����! �9�4 4 �1�&'+23
�=�
& ��:�=�����! �9�4 4 �1��&'+23
�=���
POW(X,Y)POW(X,Y)& ��:�=�����! �$4 : 1'#'23
�=�
& ��:�=�����! �$4 : 1'#�'23
�=��6��
ROUND(N,M)ROUND(N,M)& ��:�=�����! ��4 ;5 �1�&)'*#'23
�=�6 �
& ��:�=�����! ��4 ;5 �1�&)'*#+23
�=�6 � ��
SQRT(x)SQRT(x)& ��:�=�����! ��� � 1*23
� ������������� �������� ������������� �������
� ��� �� ��� � ����)/)/������� ���� ������������� ���� ������
& ��:�=�����! ��� � 1*23
�=��
& ��:�=�����! ��� � 1'/23
�=� 6 �� �"� """�
TRUNCATE(X,D)TRUNCATE(X,D)& ��:�=�����! � �;5 !� �1�&)'*#'23
�=�6 �
& ��:�=�����! � �;5 !� �1�''#�'23
�=���
ASCII(ASCII(strstr))..& ��:�=�����! ���!��1<'<23
�=���
& ��:�=�����! ���!��1'23
�=���
& ��:�=�����! ���!��1< =<23
�=���
BIN(N)BIN(N)
���� �� ����������� �� �������
� ��� �� ��� � ����)�)�������� ���� ������������� ���� ������
BIN(N)BIN(N)& ��:�=�����! ���5 1�'23
�=�@��?
BIT_LENGTH(BIT_LENGTH(strstr))& ��:�=�����! ���5 18�'823
�=��
CHAR(N,... [USING CHAR(N,... [USING charset_namecharset_name])])& ��:�=�����! �!>��1,,#�'�#-)#-�#<,�<23
�=�@' ��A /@
& ��:�=�����! �!>��1,,#,,&)#<,,&)<23
�=�@' ' ' @
CONCAT()CONCAT()& ��:�=�����! �!4 5 !� 1<� �<#�<�<#�<� �<23
���� �� ����������� �� �������
� ��� �� ��� � ����)')'������� ���� ������������� ���� ������
& ��:�=�����! �!4 5 !� 1<� �<#�<�<#�<� �<23
�=�@' ��A /@
& ��:�=�����! �!4 5 !� 1<� �<#�5 ;��#�<� �<23
�=�% �//
CONCAT_WS(separator,str1,str2,...)CONCAT_WS(separator,str1,str2,...)& ��:�=�����! �!4 5 !� ?: �1<#<#<9������� <#<���� ��� <#<����5 �� <23
�=�@��������& �B��$�� ��& �B/��� %�& �@
& ��:�=�����! �!4 5 !� ?: �1<#<#<9������� <#5 ;��#<����5 �� <23
�=�@��������& �B/��� %�& �@
ELT(N,str1,str2,str3,...)ELT(N,str1,str2,str3,...)& ��:�=�����! ��� 1�#�<@<#�<>@�<#�<�@<#�<���<23
�=�@�C@
& ��:�=�����! ��� 1*#�<@<#�<>@�<#�<�@<#�<���<23
�=�@�@
FIELD(str,str1,str2,str3,...)FIELD(str,str1,str2,str3,...)& ��:�=�����! �9����1<@<#�<>@<#�<@<#�<>@�<#�<�@<#�<���<23
���� �� ����������� �� �������
� ��� �� ��� � ����))))������� ���� ������������� ���� ������
& ��:�=�����! �9����1<@<#�<>@<#�<@<#�<>@�<#�<�@<#�<���<23
�=��
& ��:�=�����! �9����1<��<#�<>@<#�<@<#�<>@�<#�<�@<#�<���<23
�=��
FIND_IN_SET(FIND_IN_SET(str,strliststr,strlist))& ��:�=�����! �9�5 �?�5 ?�� 1<%<#<�#%#�# <23
�=��
& ��:�=�����! �9�5 �?�5 ?�� 17'//<#7�,#*+#�,#'//#)//<23
�=�
FORMAT(X,D)FORMAT(X,D)& ��:�=�����! �94 �� � 1�'))'&�')*+�#�*23
�=�@�B �6� �@
& ��:�=�����! �94 �� � 1�'))'&�#*23
�=�@�B �6���?
HEX(HEX(N_or_SN_or_S))& ��:�=�����! �>�A1'++23
���� �� ����������� �� �������
� ��� �� ��� � ����)*)*������� ���� ������������� ���� ������
& ��:�=�����! �>�A1'++23
�=�@��>
& ��:�=�����! �>�A1<�%�<23
�=�����
INSERT(INSERT(str,pos,len,newstrstr,pos,len,newstr))& ��:�=�����! ��5 ��� 1<� �� ����<#�)#�*#�<: ���<23
�=�@A �D �����$>
& ��:�=�����! ��5 ��� 1<� �� ����<#���#�*#�<: ���<23
�=�@A �������$@
INSTR(INSTR(str,substrstr,substr))& ��:�=�����! ��5 � �1<���%�%�<#�<%�<23
�=�
& ��:�=�����! ��5 � �1<=%�<#�<���%�<23
�=��
LCASE(LCASE(strstr))& ��:�=�����! ��!���17��� $� ������823
���� �� ����������� �� �������
� ��� �� ��� � ����)+)+������� ���� ������������� ���� ������
& ��:�=�����! ��!���17��� $� ������823
�=�>��& )���������>
& ��:�=�����! ��!���18)����B�5;��0�'//-<23
�=�? ���C������ ���!?
INSERT(INSERT(str,pos,len,newstrstr,pos,len,newstr))& ��:�=�����! ��5 ��� 1<� �� ����<#�)#�*#�<: ���<23
�=�@A �D �����$>
& ��:�=�����! ��5 ��� 1<� �� ����<#���#�*#�<: ���<23
�=�@A �������$@
LEFT(LEFT(str,lenstr,len))& ��:�=�����! ���9 17 ������<#�+23
�=�>�����?
& ��:�=�����! ���9 1�')*+�#�)23
�=�>� ?
LENGTH(LENGTH(strstr))& ��:�=�����! ���5 C >17��� $� ������823
���� �� ����������� �� �������
� ��� �� ��� � ����)�)�������� ���� ������������� ���� ������
& ��:�=�����! ���5 C >17��� $� ������823
�=�
& ��:�=�����! ���5 C >1�')*+�23
�=��
LPAD(LPAD(str,pos,len,padstrstr,pos,len,padstr))& ��:�=�����! ��$��17��� $<#�,#8D<23
�=�>EEE/*' #>
& ��:�=�����! ��$��17��� $<#�'#8D823
�=�>/*@
LTRIM(LTRIM(strstr))& ��:�=�����! �� ��� 17������������� ������823
�=�>��������?
& ��:�=�����! �� ��� 17��������������� $� ��������������723
�=�7��� $� ��������������7
MID(MID(str,pos,lenstr,pos,len))& ��:�=�����! �� ��17��� $� ������8#�#+23
���� �� ����������� �� �������
� ��� �� ��� � ����),),������� ���� ������������� ���� ������
& ��:�=�����! �� ��17��� $� ������8#�#+23
�=�>�����?
& ��:�=�����! �� ��1�')*+�#)#'23
�=�? ?
REPEAT(REPEAT(str,countstr,count))& ��:�=�����! ���$�� 17>��<#�)23
�=�>3��3�3�>
& ��:�=�����! ���$�� 1�/#�'23
�=�>��?
REVERSE(REVERSE(strstr))& ��:�=�����! ���6����17: ��823
�=�>�*D ?
& ��:�=�����! ���6����1//,23
�=�>,8
RIGHT(RIGHT(str,lenstr,len))& ��:�=�����! ���C> 17��� $� ������8#)23
���� �� ����������� �� �������
� ��� �� ��� � ����)-)-������� ���� ������������� ���� ������
& ��:�=�����! ���C> 17��� $� ������8#)23
�=�>���?
& ��:�=�����! ���C> 1�'///#)23
�=�>���?
RPAD(RPAD(str,len,padstrstr,len,padstr))& ��:�=�����! ��$��17��� $�<#�-#�7D823
�=�>/*' #EEEE>
& ��:�=�����! ��$��1/+/#�*#+/23
�=�>����?
SPACE(10)SPACE(10)& ��:�=�����! ��$�!�1�/23
�=�>����������?
& ��:�=�����! ��$�!�1�-23
�=�>8
TRIM(TRIM(strstr))& ��:�=�����! � ��� 17��������������� $� ��������������������������823
���� �� ����������� �� �������
� ��� �� ��� � ����).).������� ���� ������������� ���� ������
& ��:�=�����! � ��� 17��������������� $� ��������������������������823
�=�>/*' #���������?
& ��:�=�����! � ��� 1��������������������������������������������������������')������������������23
�=�>� ?
UNHEX(UNHEX(strstr))& ��:�=�����! �;5 >�A17*!*�*�+/823
�=�>/*' #>
& ��:�=�����! �;5 >�A17*!*�*�+C 823
�=�% �//
ADDDATE(ADDDATE(date,INTERVALdate,INTERVAL exprexpr unit)unit)& ��:�=�����! ������ �17'//-�/��)�8#���E���'� ��23
�=�>���!������?
& ��:�=�����! ������ �17'//-�/��)�8#���E���+�� ����23
�=�>���!���� ?
CURDATE()CURDATE()& ��:�=�����! �!;��� �123
������ ������������� �������
� ��� �� ��� � ����*/*/������� ���� ������������� ���� ������
& ��:�=�����! �!;��� �123
�=�>���!��� ?
& ��:�=�����! �!;��� �12F�.3
�=����!���
DATEDIFF(exp1, exp2)DATEDIFF(exp1, exp2)& ��:�=�����! ��� ���991��( 12#8�.,+�/'�/+823
�=��� !
& ��:�=�����! ��� ���991��( 12#8�.*,�/-��+823
�=����!
MAKETIME(MAKETIME(hr,min,sechr,min,sec))& ��:�=�����! �� �G� �� �1�'#*/#+'23
�=�?�4 �4��?
& ��:�=�����! �� �G� �� �1�'#*/#�+'23
�=�% �//
CURTIME()CURTIME()& ��:�=�����! �!;� �� �123
������ ������������� �������
� ��� �� ��� � ����*�*�������� ���� ������������� ���� ������
& ��:�=�����! �!;� �� �123
�=�?�4�4!?
& ��:�=�����! �!;� �� �12F)/3
�=��� !6������
TIME_TO_SEC(x)TIME_TO_SEC(x)& ��:�=�����! � �� �? 4 ?��!18�/H'/H/)823
�=� ���
& ��:�=�����! � �� �? 4 ?��!18)/H'/H/)823
�=��"��
� ��� �� ��� � ����*'*'������� ���� ������������� ���� ������
Single line QuerySingle line Querymysql> select VERSION(), CURDATE() ;+-----------------------+------------+| VERSION() | CURDATE() |+-----------------------+------------+| 6.0.3-alpha-community | 2008-01-21 |+-----------------------+------------+
� ��� �� ��� � ����*)*)������� ���� ������������� ���� ������
+-----------------------+------------+1 row in set (0.08 sec)
mysql>
Multiple line QueryMultiple line Querymysql> select VERSION(); select curdate();+-----------------------+| VERSION() |+-----------------------+| 6.0.3-alpha-community |+-----------------------+1 row in set (0.00 sec)
� ��� �� ��� � ����****������� ���� ������������� ���� ������
+------------+| curdate() |+------------+| 2008-01-21 |+------------+1 row in set (0.00 sec)
mysql>
The Delimiter (;)The Delimiter (;)mysql> select USER()
-> ,-> CURDATE(),-> curtime();
+----------------+------------+-----------+| USER() | CURDATE() | curtime() |+----------------+------------+-----------+| root@localhost | 2008-01-21 | 12:18:56 |+----------------+------------+-----------+
� ��� �� ��� � ����*+*+������� ���� ������������� ���� ������
+----------------+------------+-----------+1 row in set (0.05 sec)
mysql>
Query TerminationQuery Terminationmysql> select
-> USER()-> \c
mysql>
�#-. *"'�#-. *"'�#-. *"'�#-. *"'�#-. *"'�#-. *"'�#-. *"'�#-. *"' )%@�� +)%$%&)%@�� +)%$%&)%@�� +)%$%&)%@�� +)%$%&)%@�� +)%$%&)%@�� +)%$%&)%@�� +)%$%&)%@�� +)%$%&
#8. ' #�#8. ' #� ' ������' ������
. A'B;9 8���� ����F $& & ���6
09 D ������ ����,� ���� � & ����)������� $& & ���6
C9 D ������ �� ��,� ����B F ������ �� $& )����� � �
������ ���� ����� F ��� � ������ :��� +G@H-6
D9 D ������ �� ��,� ����B F ������ �� $& )����� � �
������ ���� ����� F ��� � ����� :��� +GIH-6
� ��� �� ��� � ����*�*�������� ���� ������������� ���� ������
D9������ ���� ����� F ��� � ����� :��� +GIH-6
E9 D ������ �� ��,� ����BF ������ �� $& )����� � ��
�������������� ����� F ��� � ��$<��$< +GJH-6
219 D ������ �� ��,� ����B F ������ �� $& )����� � �
$& & ��� ���� ����� F ��� KE6
Creating and Using DatabasesCreating and Using Databasesmysql> create database LAMP;Query OK, 1 row affected (0.00 sec)
mysql>
mysql> use LAMP;Database changed
� ��� �� ��� � ����*,*,������� ���� ������������� ���� ������
mysql>
Creating TablesCreating Tablesmysql> show tables;Empty set (0.00 sec)
mysql> create table fruits(-> id int(5) auto_increment primary key,-> name varchar(25),-> color varchar(15)) engine=myisam;
Query OK, 0 rows affected (0.16 sec)
� ��� �� ��� � ����*-*-������� ���� ������������� ���� ������
mysql> show tables;+----------------+| Tables_in_lamp |+----------------+| fruits |+----------------+1 row in set (0.00 sec)
mysql>
Structure of the TableStructure of the Tablemysql> desc fruits;+-------+-------------+------+-----+---------+----------------+| Field | Type | Null | Key | Default | Extra |+-------+-------------+------+-----+---------+----------------+| id | int(5) | NO | PRI | NULL | auto_increment || name | varchar(25) | YES | | NULL | || color | varchar(15) | YES | | NULL | |+-------+-------------+------+-----+---------+----------------+3 rows in set (0.05 sec)
� ��� �� ��� � ����*.*.������� ���� ������������� ���� ������
3 rows in set (0.05 sec)
mysql>
Working with TablesWorking with Tablesmysql> select * from fruits;Empty set (0.00 sec)
mysql> insert into fruits(name,color) value ('apple','red');Query OK, 1 row affected (0.00 sec)
mysql> select count(*) from fruits;
� ��� �� ��� � ����+/+/������� ���� ������������� ���� ������
+----------+| count(*) |+----------+| 1 |+----------+1 row in set (0.00 sec)
Working with TablesWorking with Tablesmysql> select * from fruits;+----+-------+-------+| id | name | color |+----+-------+-------+| 1 | apple | red |+----+-------+-------+1 row in set (0.00 sec)
insert into fruits values ('1','orange','orange');
� ��� �� ��� � ����+�+�������� ���� ������������� ���� ������
mysql> insert into fruits values ('1','orange','orange');ERROR 1062 (23000): Duplicate entry '1' for key 'PRIMARY'mysql>
The effects of auto incrementThe effects of auto incrementmysql> insert into fruits(id,name,color) values (‘2’,‘cherry’,’red’);Query Ok, 1 row affected (0.00 sec)
mysql> insert into fruits(name,color) values (‘banana’,’yellow’);Query Ok, 1 row affected (0.00 sec)
mysql> insert into fruits(id,name,color) values (‘7’,‘grape’,’black’);Query Ok, 1 row affected (0.00 sec)
mysql> insert into fruits(name,color) values (‘mango’,’yellow’);
� ��� �� ��� � ����+'+'������� ���� ������������� ���� ������
mysql> insert into fruits(name,color) values (‘mango’,’yellow’);Query Ok, 1 row affected (0.00 sec)
mysql> insert into fruits(id,name,color) values (‘6’,‘goa’,’green’);Query Ok, 1 row affected (0.00 sec)
mysql> insert into fruits values (null,‘suppota’,’brown’);Query Ok, 1 row affected (0.00 sec)
mysql> insert into fruits(name,color) values (‘jack’,’green’);Query Ok, 1 row affected (0.00 sec)
The effects of auto increment (The effects of auto increment (Look at the id valueLook at the id value))mysql> select * from fruits;+----+---------+--------+| id | name | color |+----+---------+--------+| 1 | apple | red || 2 | cherry | red || 3 | banana | yellow || 7 | grape | black |
� ��� �� ��� � ����+)+)������� ���� ������������� ���� ������
| 8 | mango | yellow || 6 | goa | green || 9 | suppota | brown || 10 | jack | green |+----+---------+--------+8 rows in set (0.00 sec)
mysql>
Sorting the recordsSorting the recordsmysql> select name,color from fruits order by color;+---------+--------+| name | color |+---------+--------+| grape | black || suppota | brown || goa | green || jack | green |
� ��� �� ��� � ����+*+*������� ���� ������������� ���� ������
| apple | red || cherry | red || banana | yellow || mango | yellow |+---------+--------+8 rows in set (0.00 sec)
mysql>
Selection with conditionsSelection with conditionsmysql> select * from fruits where color='red';+----+--------+-------+| id | name | color |+----+--------+-------+| 1 | apple | red || 2 | cherry | red |+----+--------+-------+2 rows in set (0.00 sec)
select * from fruits where color='red' or color='yellow';
� ��� �� ��� � ����++++������� ���� ������������� ���� ������
mysql> select * from fruits where color='red' or color='yellow';+----+--------+--------+| id | name | color |+----+--------+--------+| 1 | apple | red || 2 | cherry | red || 3 | banana | yellow || 8 | mango | yellow |+----+--------+--------+4 rows in set (0.00 sec)
Selection with conditionsSelection with conditionsmysql> select * from fruits
-> where (color='red' or color='yellow') and length(name) > 5;+----+--------+--------+| id | name | color |+----+--------+--------+| 2 | cherry | red || 3 | banana | yellow |+----+--------+--------+
� ��� �� ��� � ����+�+�������� ���� ������������� ���� ������
2 rows in set (0.00 sec)
mysql> select * from fruits where name like '%o%';+----+---------+--------+| id | name | color |+----+---------+--------+| 8 | mango | yellow || 6 | goa | green || 9 | suppota | brown |+----+---------+--------+3 rows in set (0.00 sec)
Selection with conditionsSelection with conditionsmysql> select * from fruits where name like '%a';+----+---------+--------+| id | name | color |+----+---------+--------+| 3 | banana | yellow || 6 | goa | green || 9 | suppota | brown |+----+---------+--------+3 rows in set (0.00 sec)
� ��� �� ��� � ����+,+,������� ���� ������������� ���� ������
mysql> select * from fruits where name like '_a%';+----+--------+--------+| id | name | color |+----+--------+--------+| 3 | banana | yellow || 8 | mango | yellow || 10 | jack | green |+----+--------+--------+3 rows in set (0.00 sec)
Copy a table with structureCopy a table with structuremysql> create table fruits1 like fruits;Query OK, 0 rows affected (0.00 sec)
mysql> create table fruits2 select * from fruits;Query OK, 8 rows affected (0.33 sec)Records: 8 Duplicates: 0 Warnings: 0
mysql> desc fruits2;
� ��� �� ��� � ����+-+-������� ���� ������������� ���� ������
+-------+-------------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+-------+-------------+------+-----+---------+-------+| id | int(5) | NO | | 0 | || name | varchar(25) | YES | | NULL | || color | varchar(15) | YES | | NULL | |+-------+-------------+------+-----+---------+-------+3 rows in set (0.01 sec)
Copy a table with structureCopy a table with structuremysql> select * from fruits2;+----+---------+--------+| id | name | color |+----+---------+--------+| 1 | apple | red || 2 | cherry | red || 3 | banana | yellow || 7 | grape | black |
� ��� �� ��� � ����+.+.������� ���� ������������� ���� ������
| 8 | mango | yellow || 6 | goa | green || 9 | suppota | brown || 10 | jack | green |+----+---------+--------+8 rows in set (0.00 sec)
mysql>
Grouping FunctionGrouping Functionmysql> select color,count(*) from fruits group by color;+--------+----------+| color | count(*) |+--------+----------+| black | 1 || brown | 1 || green | 2 || red | 2 |
� ��� �� ��� � �����/�/������� ���� ������������� ���� ������
| red | 2 || yellow | 2 |+--------+----------+5 rows in set (0.08 sec)
Grouping FunctionGrouping Functionmysql> select color,count(*) as cnt from fruits group by color order by cnt;+--------+-----+| color | cnt |+--------+-----+| black | 1 || brown | 1 || red | 2 || yellow | 2 |
� ��� �� ��� � ��������������� ���� ������������� ���� ������
| yellow | 2 || green | 2 |+--------+-----+5 rows in set (0.00 sec)
Grouping FunctionGrouping Functionmysql> select color,count(*) as cnt from fruits group by color order by cnt desc;+--------+-----+| color | cnt |+--------+-----+| red | 2 || yellow | 2 || green | 2 || black | 1 |
� ��� �� ��� � �����'�'������� ���� ������������� ���� ������
| black | 1 || brown | 1 |+--------+-----+5 rows in set (0.00 sec)
mysql>
Altering TableAltering Tablemysql> alter table fruits add rate float(3,2) default 0.0;Query OK, 8 rows affected (0.28 sec)Records: 8 Duplicates: 0 Warnings: 0
mysql> select * from fruits;+----+---------+--------+------+| id | name | color | rate |+----+---------+--------+------+| 1 | apple | red | 0.00 || 2 | cherry | red | 0.00 |
� ��� �� ��� � �����)�)������� ���� ������������� ���� ������
| 2 | cherry | red | 0.00 || 3 | banana | yellow | 0.00 || 7 | grape | black | 0.00 || 8 | mango | yellow | 0.00 || 6 | goa | green | 0.00 || 9 | suppota | brown | 0.00 || 10 | jack | green | 0.00 |+----+---------+--------+------+8 rows in set (0.00 sec)
Mysql>
Updating the RecordsUpdating the Recordsmysql> update fruits set rate=5 where name='apple' or name='mango';Query OK, 2 rows affected (0.05 sec)Rows matched: 2 Changed: 2 Warnings: 0
mysql> update fruits set rate=0.5 where name in ('cherry','grape');Query OK, 2 rows affected (0.06 sec)Rows matched: 2 Changed: 2 Warnings: 0
� ��� �� ��� � �����*�*������� ���� ������������� ���� ������
Rows matched: 2 Changed: 2 Warnings: 0
mysql> update fruits set rate=2.25 where rate=0;Query OK, 4 rows affected (0.00 sec)Rows matched: 4 Changed: 4 Warnings: 0
mysql>
Updating the RecordsUpdating the Recordsmysql> select * from fruits;+----+---------+--------+------+| id | name | color | rate |+----+---------+--------+------+| 1 | apple | red | 5.00 || 2 | cherry | red | 0.50 || 3 | banana | yellow | 2.25 || 7 | grape | black | 0.50 || 8 | mango | yellow | 5.00 |
� ��� �� ��� � �����+�+������� ���� ������������� ���� ������
| 8 | mango | yellow | 5.00 || 6 | goa | green | 2.25 || 9 | suppota | brown | 2.25 || 10 | jack | green | 2.25 |+----+---------+--------+------+8 rows in set (0.00 sec)
mysql>
More than one tableMore than one tablemysql> create table purchase(
-> fruit varchar(25), qty int(3) default 0)engine=myisam;Query OK, 0 rows affected (0.11 sec)
mysql> load data local infile 'c:/buy.txt' into table purchase fields terminated by ',' lines terminated by '\r\n';Query OK, 4 rows affected (0.05 sec)Records: 4 Deleted: 0 Skipped: 0 Warnings: 0
mysql> select * from purchase;
� ��� �� ��� � ��������������� ���� ������������� ���� ������
+--------+------+| fruit | qty |+--------+------+| apple | 5 || grape | 30 || goa | 3 || banana | 12 |+--------+------+4 rows in set (0.00 sec)
mysql>
Combined QueryCombined Querymysql> select a.name,a.rate,b.qty,b.qty*a.rate as amount from fruits a, purchase b where a.name=b.fruit;+--------+------+------+--------+| name | rate | qty | amount |+--------+------+------+--------+| apple | 5.00 | 5 | 25.00 || banana | 2.25 | 12 | 27.00 || grape | 0.50 | 30 | 15.00 || goa | 2.25 | 3 | 6.75 |+--------+------+------+--------+4 rows in set (0.00 sec)
� ��� �� ��� � �����,�,������� ���� ������������� ���� ������
4 rows in set (0.00 sec)
mysql> select sum(b.qty*a.rate) as amount from fruits a, purchase b where a.name=b.fruit;+--------+| amount |+--------+| 73.75 |+--------+1 row in set (0.05 sec)
mysql>
IndexingIndexingmysql> create index index1 on fruits(rate,color);Query OK, 8 rows affected (0.14 sec)Records: 8 Duplicates: 0 Warnings: 0
mysql> show keys from fruits;+--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_Comment |+--------+------------+----------+--------------+-------------+-----------
� ��� �� ��� � �����-�-������� ���� ������������� ���� ������
+--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+| fruits | 0 | PRIMARY | 1 | id | A |
8 | NULL | NULL | | BTREE | | || fruits | 1 | index1 | 1 | rate | A |
NULL | NULL | NULL | YES | BTREE | | || fruits | 1 | index1 | 2 | color | A |
NULL | NULL | NULL | YES | BTREE | | |+--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+3 rows in set (0.00 sec)
mysql>
Stored Stored -- FunctionsFunctionsmysql>select rate from lamp.fruits where fruit=’apple’;+------+| rate |+------+| 5.00 |+------+1 row in set (0.00 sec)
mysql> delimiter |;mysql> create function GetFruitRate(item varchar(20))
-> returns float-> deterministic
� ��� �� ��� � �����.�.������� ���� ������������� ���� ������
-> deterministic-> begin-> declare rt float;-> select rate into rt from lamp.fruits where name=item;-> return rt;-> end|
Query OK, 0 rows affected (0.14 sec)
mysql> select GetFruitRate('banana');+------------------------+| GetFruitRate('banana') |+------------------------+| 2.25 |+------------------------+1 row in set (0.00 sec)
Listing all the available stored functionsListing all the available stored functionsmysql> show function status\G*************************** 1. row ***************************
Db: lampName: GetFruitRateType: FUNCTION
Definer: root@localhostModified: 2008-01-25 12:27:27Created: 2008-01-25 12:27:27
� ��� �� ��� � ����,/,/������� ���� ������������� ���� ������
Created: 2008-01-25 12:27:27Security_type: DEFINER
Comment:character_set_client: latin1collation_connection: latin1_swedish_ciDatabase Collation: latin1_swedish_ci
1 row in set (0.00 sec)mysql>
To view the code To view the code mysql> show create function GetFruitRate\G*************************** 1. row ***************************
Function: GetFruitRatesql_mode: STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER
Create Function: CREATE DEFINER=`root`@`localhost` FUNCTION `GetFruitRate`(item varchar(20)) RETURNS float
DETERMINISTICbegin
� ��� �� ��� � ����,�,�������� ���� ������������� ���� ������
begindeclare rt float;select rate into rt from lamp.fruits where name=item;return rt;endcharacter_set_client: latin1collation_connection: latin1_swedish_ciDatabase Collation: latin1_swedish_ci
1 row in set (0.00 sec)
mysql>
ProceduresProceduresmysql> delimiter |mysql> create procedure ChangeFruitRate(item varchar(20), newrate float)
-> begin-> declare cnt int;-> select count(*) into cnt from lamp.fruits where
name=item;-> if cnt>0 then-> update lamp.fruits set rate=newrate where
name=item;
� ��� �� ��� � ����,','������� ���� ������������� ���� ������
name=item;-> select name,rate from lamp.fruits where name=item;-> else-> select concat(item, ' not available in the fruits
table') as Error;-> end if;-> end|
Query OK, 0 rows affected (0.09 sec)
ProceduresProceduresmysql> delimiter ;mysql> call ChangeFruitRate('apple',6.50);+-------+------+| name | rate |+-------+------+| apple | 6.50 |+-------+------+1 row in set (0.00 sec)
Query OK, 0 rows affected (0.02 sec)mysql> select * from fruits;+----+---------+--------+------+
� ��� �� ��� � ����,),)������� ���� ������������� ���� ������
+----+---------+--------+------+| id | name | color | rate |+----+---------+--------+------+| 1 | apple | red | 6.50 || 2 | cherry | red | 0.50 || 3 | banana | yellow | 2.25 || 7 | grape | black | 0.50 || 8 | mango | yellow | 5.00 || 6 | goa | green | 2.25 || 9 | suppota | brown | 2.25 || 10 | jack | green | 2.25 |+----+---------+--------+------+8 rows in set (0.00 sec)
mysql>
ProceduresProceduresmysql> call ChangeFruitRate('orange',6.50);+------------------------------------------+| Error |+------------------------------------------+| orange not available in the fruits table |+------------------------------------------+1 row in set (0.00 sec)
Query OK, 0 rows affected (0.02 sec)
� ��� �� ��� � ����,*,*������� ���� ������������� ���� ������
mysql>
TriggerTriggermysql> create table log(time datetime, task varchar(200)engine=myisam;Query OK, 0 rows affected (0.02 sec)
mysql> delimiter |mysql> create trigger LogRateChange after update on fruits
-> for each row-> begin-> insert into log values(now(),concat(new.name,' rate
� ��� �� ��� � ����,+,+������� ���� ������������� ���� ������
changed from ', old.rate, ' to ', new.rate));-> end;-> |
Query OK, 0 rows affected (0.00 sec)
mysql> delimiter ;mysql> update fruits set rate='7.5' where name='apple';Query OK, 1 row affected (0.00 sec)
TriggerTriggermysql> select * from fruits;+----+---------+--------+------+| id | name | color | rate |+----+---------+--------+------+| 1 | apple | red | 7.50 || 2 | cherry | red | 0.50 || 3 | banana | yellow | 2.25 || 7 | grape | black | 0.50 || 8 | mango | yellow | 5.00 || 6 | goa | green | 4.50 || 9 | suppota | brown | 2.25 || 10 | jack | green | 2.25 |
� ��� �� ��� � ����,�,�������� ���� ������������� ���� ������
| 10 | jack | green | 2.25 |+----+---------+--------+------+8 rows in set (0.00 sec)
mysql> select * from log;+---------------------+--------------------------------------+| time | task |+---------------------+--------------------------------------+| 2008-01-25 14:21:38 | apple rate changed from 6.50 to 7.50 |+---------------------+--------------------------------------+1 row in set (0.00 sec)
mysql>
ViewsViewsmysql> create view myfruits as select name, rate from fruits;Query OK, 0 rows affected (0.00 sec)
mysql> show tables;+----------------+| Tables_in_lamp |+----------------+| fruits |
� ��� �� ��� � ����,,,,������� ���� ������������� ���� ������
| fruits1 || log || myfruits || purchase |+----------------+5 rows in set (0.00 sec)
ViewsViewsmysql> select * from myfruits;+---------+------+| name | rate |+---------+------+| apple | 7.50 || cherry | 0.50 || banana | 2.25 || grape | 0.50 || mango | 5.00 |
� ��� �� ��� � ����,-,-������� ���� ������������� ���� ������
| goa | 4.50 || suppota | 2.25 || jack | 2.25 |+---------+------+8 rows in set (0.00 sec)
mysql>
User ManagementUser ManagementCreate a new userCreate a new usermysql> grant all privileges on lamp.* to 'myfriend'@'localhost' identified by ‘myfriend';Query OK, 0 rows affected (0.09 sec)
Login from another terminal as Login from another terminal as myfriendmyfriend
C:\>mysql -u root -pEnter password: ******Welcome to the MySQL monitor. Commands end with ; or \g.
� ��� �� ��� � ����,.,.������� ���� ������������� ���� ������
Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 8Server version: 6.0.3-alpha-community MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use lampDatabase changedmysql> update fruits set rate=5.0 where name='apple';Query OK, 1 row affected (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 0
Mysql>
Revoke the update privilege from Revoke the update privilege from myfriendmyfriend
mysql> revoke update on lamp.* from 'myfriend'@'localhost';Query OK, 0 rows affected (0.00 sec)
mysql>
If If myfriendmyfriend try to update againtry to update again
mysql> update fruits set rate=5.0 where name='apple';
� ��� �� ��� � ����-/-/������� ���� ������������� ���� ������
mysql> update fruits set rate=5.0 where name='apple';ERROR 1142 (42000): UPDATE command denied to user 'myfriend'@'localhost' for table 'fruits'mysql>
Deleting a recordDeleting a recordmysql> select * from fruits2;+----+---------+--------+| id | name | color |+----+---------+--------+| 1 | apple | red || 2 | cherry | red || 3 | banana | yellow || 7 | grape | black || 8 | mango | yellow |
� ��� �� ��� � ����-�-�������� ���� ������������� ���� ������
| 8 | mango | yellow || 6 | goa | green || 9 | suppota | brown || 10 | jack | green |+----+---------+--------+8 rows in set (0.00 sec)
mysql> delete from fruits2 where color='green';Query OK, 2 rows affected (0.24 sec)
Deleting a recordDeleting a recordmysql> select * from fruits2;+----+---------+--------+| id | name | color |+----+---------+--------+| 1 | apple | red || 2 | cherry | red || 3 | banana | yellow || 7 | grape | black || 8 | mango | yellow |
� ��� �� ��� � ����-'-'������� ���� ������������� ���� ������
| 8 | mango | yellow || 9 | suppota | brown |+----+---------+--------+6 rows in set (0.00 sec)
mysql>
Dropping a tableDropping a tablemysql> truncate table fruits2;Query OK, 6 rows affected (0.28 sec)
mysql> select * from fruits2;Empty set (0.00 sec)
mysql> drop table fruits2;Query OK, 0 rows affected (0.16 sec)
� ��� �� ��� � ����-)-)������� ���� ������������� ���� ������
mysql> show tables;+----------------+| Tables_in_lamp |+----------------+| fruits || fruits1 || purchase |+----------------+3 rows in set (0.06 sec)
Dropping a databaseDropping a databasemysql> drop database lamp;Query OK, 0 rows affected (0.00 sec)
mysql> select database();+------------+| database() |+------------+| NULL |+------------+
� ��� �� ��� � ����-*-*������� ���� ������������� ���� ������
+------------+1 row in set (0.00 sec)
mysql>
Quit from Quit from mysqlmysql promptpromptmysql> exitBye
C:\>
� ��� �� ��� � ����-+-+������� ���� ������������� ���� ������
C:\>
� ��� �� ��� � ����-�-�������� ���� ������������� ���� ������
������