Home > Database > Mysql Tutorial > body text

mysqL学习之实例_MySQL

WBOY
Release: 2016-06-01 13:51:55
Original
1004 people have browsed it

好久没有谈数据库的技巧了,当然我也不是什么高手,所以,还是那句话,高手莫来,来之莫怪!哈哈!
一、操作技巧

1、如果你打命令时,回车后发现忘记加分号,你无须重打一遍命令,只要打个分号回车就可以了。也就是说你可以把一个完整的命令分成几行来打,完后用分号作结束标志就OK。

2、你可以使用光标上下键调出以前的命令。但以前我用过的一个MYSQL旧版本不支持。我现在用的是mysql-3.23.27-beta-win。

 

二、显示命令

1、显示数据库列表。

show databases;
 

2、显示库中的数据表:

use mysql; //打开库

show tables;

3、显示数据表的结构:

describe 表名;

4、建库:

create database 库名;

5、建表:

use 库名;

create table 表名 (字段设定列表);

6、删库和删表:

drop database 库名;

drop table 表名;

7、将表中记录清空:

delete from 表名;

8、显示表中的记录:

select * from 表名;

 

三、一个建库和建表以及插入数据的实例

drop database if exists school; //如果存在SCHOOL则删除

create database school; //建立库SCHOOL

use school; //打开库SCHOOL

create table teacher //建立表TEACHER

(

id int(3) auto_increment not null primary key,

name char(10) not null,

address varchar(50) default '深圳',

year date

); //建表结束

//以下为插入字段

insert into teacher values('','glchengang','深圳一中','1976-10-10');

insert into teacher values('','jack','深圳一中','1975-12-23');

 

 


后记:其实MYSQL的对数据库的操作与其它的SQL类数据库大同小异,您最好找本将SQL的书看看。我是一个比较懒的人,再说我最近的工作比较忙,忙着录音电话系统的处理,唉,生活啊!

绿色通道:好文要顶关注我收藏该文与我联系
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!