最近在学习mysql数据库,一些记录总结
2013-04-04 22:40
393 查看
在window xp上使用mysql-installer-community-5.5.30.1.msi装了相应版本的mysql。可从http://dev.mysql.com/获取相应的安装包。本来想装5.6的版本,发现官网声明5.6版本不支持window xp,就没装。装的过程发现需要.net framework相关东西,直接在360的软件管理中安装了.net framework,安全方便。
安装完毕后,在
在开始-程序-mysql中启动mysql workbench,按照官网的介绍尝试了下面的命令,
using mysql work bench:
1,query operation:
select VERSION(),CURRENT_DATE;
select SIN(PI()/4),(4+1)*5;
select version();
select now();
select user();
2, Use the show statement to find out what databases currently exist on the server:
show databases;
3,create database:
create database bestree;
4,create a table:
show tables;
create table pet(name varchar(20),owner varchar(20),
species varchar(20),sex char(1),birth date,death date);
5,show tables;
describe pet;
6,
load data local infile 'E:\pet.txt' into table pet lines terminated by '\r\n';
7,
insert into pet values('bestree','best','fa','f','1988-3-4',NULL);
as you can see
String and date values are specified as quoted strings here.and
you can insert NULL directly to represent a missing value
8,select
select * from pet where name='bestree';
select * from pet;
select * from pet where birth>='1988-2-28';
select * from pet where (species='cat' and sex='m')or (species='dog' and sex='f');
9, select particular column
select name,birth from pet;
10,order by
select name,birth from pet order by birth;
感觉还不错。
后来想通过eclipse写java代码访问下数据库,于是百度了下,下面代码参考了百度的结果
运行上面代码之前,需要将mysql-connector-java-5.1.23-bin.jar包放置到classpath目录。
有尝试了下面的命令
1,查看目前选中的数据库:
select database();
2,查看当前数据库下的表:
show tables;
3,查看每个表的结构:
desc pet;
4,查看某个表的索引:
show index from pet;
安装完毕后,在
在开始-程序-mysql中启动mysql workbench,按照官网的介绍尝试了下面的命令,
using mysql work bench:
1,query operation:
select VERSION(),CURRENT_DATE;
select SIN(PI()/4),(4+1)*5;
select version();
select now();
select user();
2, Use the show statement to find out what databases currently exist on the server:
show databases;
3,create database:
create database bestree;
4,create a table:
show tables;
create table pet(name varchar(20),owner varchar(20),
species varchar(20),sex char(1),birth date,death date);
5,show tables;
describe pet;
6,
load data local infile 'E:\pet.txt' into table pet lines terminated by '\r\n';
7,
insert into pet values('bestree','best','fa','f','1988-3-4',NULL);
as you can see
String and date values are specified as quoted strings here.and
you can insert NULL directly to represent a missing value
8,select
select * from pet where name='bestree';
select * from pet;
select * from pet where birth>='1988-2-28';
select * from pet where (species='cat' and sex='m')or (species='dog' and sex='f');
9, select particular column
select name,birth from pet;
10,order by
select name,birth from pet order by birth;
感觉还不错。
后来想通过eclipse写java代码访问下数据库,于是百度了下,下面代码参考了百度的结果
public class Test { public static void main(String[] args) { String driver = "com.mysql.jdbc.Driver"; try { Class.forName(driver); // 连续数据库 Connection conn = DriverManager .getConnection("jdbc:mysql://localhost:3306/bestree", "bestree", ""); if (!conn.isClosed()) { System.out.println("Succeeded connecting to the Database!"); } // statement用来执行SQL语句 Statement statement = conn.createStatement(); // 要执行的SQL语句 String sql = "select * from pet"; ResultSet rs = statement.executeQuery(sql); while (rs.next()) { String name = rs.getString("name"); System.out.println(name); } rs.close(); conn.close(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { } } }
运行上面代码之前,需要将mysql-connector-java-5.1.23-bin.jar包放置到classpath目录。
有尝试了下面的命令
1,查看目前选中的数据库:
select database();
2,查看当前数据库下的表:
show tables;
3,查看每个表的结构:
desc pet;
4,查看某个表的索引:
show index from pet;
相关文章推荐
- 最近学习易语言核心支持库的一些记录
- 最近在学习Linux,下面是一些学习笔记,以后会不定期更新,以此做总结.
- 最近打算开始学游戏开发,故此先记录一些Unity的学习网站
- android小白最近学习的界面的一些总结
- 最近在学习云服务器,一些学习笔记记录下来,留着以后查看
- 最近在ArcGIS Engine开发中关于调用gp工具过程出现COM 组件的调用返回了错误 HRESULT E_FAIL 错误的解决方法 和 学习oracle中遇到的一些问题总结
- 记录最近web的一些学习和后面的计划
- 关情纸尾-----关于最近学习iOS开发的一些总结(一)
- 最近学习的一些记录
- 慕客网学习总结:mysql数据库,操作数据表中的记录
- 【ssh2学习记录】3、关于ssh2框架整合以及hibernate的一些总结
- 最近学习安卓中总结的一些知识点 复制代码
- 最近学习vc时候的一些总结
- 最近学习安卓中总结的一些知识点
- 最近的学习笔记,记录一些通俗易懂的学习类文章。更像是好资料参与索引。
- 最近的学习笔记,记录一些通俗易懂的学习类文章。更像是好资料参与索引。
- 关于最近学习的一些方法总结
- 最近才开通的博客~与大家一起分享之前总结的一些学习经验~~~Java陷阱小结
- kotlin学习记录以及一些疑问
- Mybatis学习(十)mybatis一些问题的总结