mysql基础:基本操作

1.显示所有数据库show  databases;  打开数据库:use dbname.

显示打开数据库中所有的数据表:   show tables;

查询表的列信息:desc tablename;       创建数据库:create database dbname;

创建表:create table tablename(......)engine=innodb/myisam.

查找mysql目录情况:system ls -lh /test/usr/local/data/mysql

启动mysql:/etc/init.d/mysqld start

关闭mysql : /bin/mysqladmin -uroot -p shutdown

mysql配置文件:/etc/my.cnf

 删除数据库:drop database 数据库名;   删除表:drop table  表名

表增加列,修改列,删除列“

增加列:alert table 表名 add 列声明

如:alert table boy add height tinyint unsigned not null default 149;

可以用after 来声明新增的列在哪一些后面

Alter table 表名 add 列声明 after  列名;

 

如果新增放在最前面

Alter table 表名 add 列声明 first;

修改列:

Alter table 表名 change 旧列名 列声明

Alter table boy change height height smallint not null default 180;(默认是180)

 

删除列:

alter table 表名drop 列名;

Alter table boy drop height;

 

给表增加列:

Alter table 表名 add 列声明 [after  列表/first]

 

修改表的列:

Alter table 表名 change 旧列名  列声明

 

删除表的列

Alter table 表名 drop 列名;

 

posted on 2013-01-14 17:22  paly76  阅读(124)  评论(0)    收藏  举报

导航