liukaiyi 发表于 2013-1-27 04:58:59

mysql(java)小结

在线文档参考
 
jdbc url: 详细属性可参考
Eg: jdbc:mysql://localhost:3306/test?user=root&password=&useUnicode=true&characterEncoding=utf8
mysql URL: mysql -uroot -p --default-character-set=utf8
 
协调 SQL 详细:
  这就重点说下:SHOW
  1. 查看全部库支持字符 如:'gb%'  -gbk,gb2312
      SHOW CHARACTER SET LIKE '%' ;
  2. 查看列
  show columns from user from mysql ;
  show columns from mysql.user ;
  desc mysql.user ;
  //简化
  //更方便的 查看 列名 模糊查询列名为 'Select%' (desc  information_schema.columns 还有更多惊喜)
  select column_name from information_schema.columns where column_name like 'Select%' ;
 
  3. 查看数据库,表结构;当然你们也可以仿照下此再建自己的库,表
   show
   show create database information_schema\G
   show create table mysql.user\G
 
  4.权限查看
   SHOW GRANTS FOR 'root'@'localhost';
  .....(详细参考)
 


SQL 详细
这就上写自己一些有感觉的sql :参考
1.只查询重复 Eg:
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;">create table c (id int );
insert into c values (1),(2),(3),(4),(3),(5),(6),(1);
结果:
    select id from c group by id having count(id)>1 ;
页: [1]
查看完整版本: mysql(java)小结