数据库 管理数据库和表

管理数据库和表

管理数据库:

  1. 创建表:create databasse 库名
  2. 连接表:use  库名
  3. 删除表:drop database 库名

数据类型:

  1. 整型数据类型:

A.Tingint 1个字节 存储数据范围0到255

B.Smallint 2个字节 -2的15次方到2的15次方-1(32767)

C.mediumint 3

D.int 4 -2的31次方到2的31次方-1

e.Bigint 8 -2的63次方到2的63次方-1

2. 浮点数据类型

a.real

b.float

c.decimal

d.numeric

3. 字符串类型

a.char

b.nchar

c.varchar

d.text

4. 二进制数据类型(后面的不常用)

管理表

  1. 创建表:create table  表名
  2. 删除表: drop table  表名
  3. 创建临时表:create table #表名
  4. 复制表: create table  新的表名

select  * from 被复制的表名(mysql中)

  1. 修改表:alter table

增加列:alter table表名 add 增加的列名

 列的数据类型;

更改列:alter table 表名change 列名

列的数据类型  约束条件

删除列:alter table 表名 drop column 列名

管理索引:创建索引:create index 索引名on

表名(列名)

删除索引: drop index 索引名

 

posted @ 2016-01-08 00:08  木古章鱼  阅读(184)  评论(0编辑  收藏  举报