宋利兴__MySQL复习2

 

MysqlJava    第十四章

今天主要讲的是mysql数据库的有关讲解大部分是对学过的知识的复习,内容归纳如下:

一。show database.//显示当前数据库中有哪些数据

create database//数据库名

系统就会在指定的文件夹创建子文件夹

create database if not exists  xxx//如果不存在xxx则创建

create database//数据库

character set//字符集的名称

collate 校验规则

show character set

alter database xsxxm//修改

character set latin1

collate latin1_swedish_ci;

drop database if exists;

drop table

二.表---在数据库里面

创建表,现指定某一个数据库是当前的数据库

use xsg;

show tables;

create table [if not exists]表名(列1 类型,列2 类型,列3 类型)

xh(id int,name char(10),sex bool,age int,score int);

select * form xs;显示所有的xs表中的信息

表格中插入数据

insert into xs values(1,'zhangs',0,18,98);

create table tab1(id char(6)not null,name char(10));//id不允许为空

show tabbles //显示所有的表格

select *from tabl;

insert into tabl(id)values('10012');

修改表格,加列。

alter table tabl

add column sex tinyint not null default 0;//添加一列性别,不允许空

myButton.setEnabled(false);

一、基本查询

1、选择列

select 列名1,列名2,。。。

from 表名

select 学号,姓名,性别,出生日期 //查询时可以不按顺序 查列

from xs;//投影查询  

select * from//*代表所有列

select 姓名 as name,学号 number//查询时把该列改名字as可以省略

from 表名

select 姓名,总学分,总学分+10 as 提高后的总学分//查询时把更改该列的数据

from 表名

select distinct 列名 //消除重复行

from 表名

select distinct 列名,列名

from 表名  

课堂笔记内容如上所示。      

posted @ 2011-09-15 14:39  Springside4  阅读(152)  评论(0编辑  收藏  举报