宋利兴__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 表名  

课堂笔记内容如上所示。      

转载于:https://www.cnblogs.com/springside4/archive/2011/09/15/2481129.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值