数据库和表的创建,删减,显示和重命名

1、数据库

(1创建数据库:create database stusys;

(2)查看数据库:show databases;

(3) 选择数据库:use stusys;

(4)修改数据库:alter database stusys

                               default character set gb2312

                               default collate gb2312_chinese_ci;

(5)删除数据库:drop database stusys;

 

2、表

(1)创建表:create table student

                        (

                         sno char(6) not null primary key,

                         sname char(8) not null,

                         ssex char(2) not null default '男',

                         sbirsday date not null,

                         speciality char(12) null,

                         tc tinyint null

                         );

(2)查看表:use stusys;

                   show tables;

 

(3)查看表的基本结构:show columns from student;或desc student;

(4)查看表的详细结构:show create table student\G

 (5)修改表-添加列:alter table stusys.student1

                    add column sid int not null unique auto_increment first;

  

  (6)修改表-修改列:alter table stusys,student1

                                change column sbirthsday sage tinyint default 18;

(7)修改表-删除列:alter table stusys.student

                                drop column sid;

 

(8) 重命名表:alter table stusys.student1

                        rename to stusys.student2;或rename stusys.student2 to stusys.student3;

(9)删除表:drop table;

 

(10)查看存储引擎:show engines;

 

 

 

 

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值