mysql ·Ö×é»ã×Ü
1.´´½¨±í£º
create table groupTable(dept varchar(6),phone varchar(20),amount int);
2.²åÈë²âÊÔÊý¾Ý£º
insert groupTable
select 'ÓªÒµ²¿',8001,20 union all
select 'ÓªÒµ²¿',8002,30 union all
select '²ÆÎñ²¿',6001,10 union all
select '²ÆÎñ²¿',6003,100;
3.mysql Óï¾ä£º
select ifnull(dept,'×ܼÆ') as '²¿ÃÅ',ifnull(phone,'С¼Æ') as 'µç»°',sum(money) as '½ð¶î' from groupTable group by
dept,phone with rollup;
4.½á¹ûÏÔʾ£º
+--------+------+------+
| ²¿ÃÅ | µç»° | ½ð¶î |
+--------+------+------+
| ²ÆÎñ²¿ | 6001 | 10 |
| ²ÆÎñ²¿ | 6003 | 100 |
| ²ÆÎñ²¿ | С¼Æ | 110 |
| ÓªÒµ²¿ | 8001 | 20 |
| ÓªÒµ²¿ | 8002 | 30 |
| ÓªÒµ²¿ | С¼Æ | 50 |
| ×Ü¼Æ | С¼Æ | 160 |
+--------+------+------+
Ïà¹ØÎĵµ£º
¡¾×¢£º¿ÉÒÔÔÚmysqlÖÐͨ¹ýmysql> SELECT VERSION();À´²é¿´Êý¾Ý¿â°æ±¾¡¿
ÕûÀí£ºleo
Ò»¡¢Á¬½ÓMYSQL¡£
¸ñʽ£º mysql -hÖ÷»úµØÖ· -uÓû§Ãû £pÓû§ÃÜÂë
1¡¢Á¬½Óµ½±¾»úÉϵÄMYSQL¡£
Ê×ÏÈ´ò¿ªDOS´°¿Ú£¬È»ºó½øÈëĿ¼mysql\bin£¬ÔÙ¼üÈëÃüÁîmysql -u root -p£¬»Ø³µºóÌáʾÄãÊäÃÜÂë.×¢ÒâÓû§ÃûÇ°¿ÉÒÔÓпոñÒ²¿ÉÒÔûÓпոñ£¬µ«ÊÇà ......
Ubuntu 9.04 ÏÂÓÃÔ´°²×°ÁËMySQL¡£Ä¬ÈÏÇé¿öÏ£¬ÓÃmysql shellµÇ¼´´½¨Êý¾Ý¿â´´½¨±í²åÈëÖÐÎÄÊý¾Ýºó£¬ÓÃselect²é³öÀ´ÊÇÖÐÎÄ£¬µ«ÓÃJDBCÁ¬½Ó¾Í³öÏÖÂÒÂë¡£ÍøÉÏËÑË÷µ½½â¾ö·½·¨£¬ÈçÏ£¨Ïȱ¸·ÝÊý¾Ý£©£º
ÐÞ¸Ä/etc/mysql/my.cnf
sudo gedit /etc/mysql/my.cnf
ÔÚmy.cnfÎļþÖеÄ[client] ......
1¡¢µÇ½MySQL:
mysql -u root -p
2¡¢²é¿´Óû§ÐÅÏ¢
select user,host,password from mysql.user;
select user,host from mysql.user;
3¡¢ÉèÖÃÃÜÂë
set password for root@localhost=password('
ÔÚÕâÀïÌîÈërootÃÜÂë
');
4¡¢ÐÞ¸ÄÃÜÂë
·½·¨1£ºmysqladmin -u root -p password newpassword
·½·¨2£º ££mysql -u root ......
ÔÚWindowsXPÖдò¿ªDOS£¬Í¨¹ýÊäÈëÃüÁî“mysql -u root -p”Çл»µ½mysqlÏ£¬Çл»Ê§°Ü£¬ÈçÏÂËùʾ£º
Microsoft Windows XP [°æ±¾ 5.1.2600]
(C) °æȨËùÓÐ 1985-2001 Microsoft Corp.
C:\>mysql -u root -p
'mysql' ²»ÊÇÄÚ²¿»òÍⲿÃüÁҲ²»ÊÇ¿ÉÔËÐеijÌÐò
»òÅú´¦ÀíÎļþ¡£
......
import java.sql.*;
/*
* JAVAÁ¬½ÓACCESS£¬SQL Server,MySQL,OracleÊý¾Ý¿â
*
* */
public class JDBC {
public static void main(String[] args)throws Exception {
Connection conn=null;
//====Á¬½ÓACCESSÊý¾Ý¿â ......