Chinaunix首页 | 论坛 | 博客
  • 博客访问: 922687
  • 博文数量: 119
  • 博客积分: 6248
  • 博客等级: 准将
  • 技术积分: 1419
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-08 14:14
文章分类

全部博文(119)

文章存档

2014年(1)

2012年(1)

2011年(2)

2010年(22)

2009年(81)

2008年(12)

分类: LINUX

2009-03-16 23:17:22

一、数据库管理:
   
    1.查看数据库
      mysql>show databases;
 
    2.创建数据库
      mysql>create database 数据库名;
 
    3.使用数据库
      mysql>use 数据库名;
 
    4.删除数据库
      mysql>drop database 数据库名;
 
二、数据表管理:
 
    1.查看数据库表
      mysql>show tables;
   
    2.查看数据表结构
      mysql>desc 数据库表名;
      mysql>show create table 表名\G;
 
    3.创建数据库表
      mysql>create table 数据库表名 (列名   类型   修饰符);
   
    4.删除数据库表
      mysql>drop table 数据库表名;
 
    5.修改,添加,删除,字段改名,字段排列顺序,更改表名:
      mysql>alter table 表名 modify 需要修改的字段  修改的类型;
      mysql>alter table 表名 add 需要添加的新字段名  字段类型;
      mysql>alter table 表名 drop 需要删除的字段名;
      mysql>alter table 表名 change 原来的字段名 新的字段名 新的字段类型;
      mysql>alter table 表名 modify|add| 字段名 字段类型 first|after 字段名;
      mysql>alter table 原数据表名 rename 新数据表名;
 
    6.创建有索引的表
      mysql>create index 索引名 on 表名 (列表);
      或者
      mysql>create table 表名 (index index1 (id,name));
 
    7.插入数据
      mysql>insert into 表名  (列表名)
            values(要插入的数据);
      或者
      mysql>insert into 表名 set 列表1=数据,列表2=数据;
 
    8.更新数据
      mysql>update 表名 set 列名1=数据1,列名2=数据2,...[where clause];
     
    9.删除数据
      mysql>delete from 表名 [where clause];
 
    10.查询数据
      mysql>select 列名1,列名2 from 表名1,表名2 [where clause];                  
             
 
阅读(2456) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~