初学者一些常用的SQL语句(一)

一、数据库的创建
create database 数据库名
create database bbb
二、表的创建
***[]:可选项
*** null:空值 not null 不为空
***只有字符型能指定长度 char varchar nchar nvarchar
create table 表名
(列名1 类型 [not null],
列名2 类型 [not null],...)
创建表6-3 class
create table class
(classno char(8) not null,
classname varchar(20) not null,
departno char(2) not null)

create table class
(classno char(8) not null,
classname varchar(20) not null,
departno char(2) not null)


create table student
(stuno char(8) not null,
stuname varchar(10) not null,
pwd char(8) not null,
classno char(8) not null)
real 实数
create table class11
(couno char(3) not null,
couname varchar(30) not null,
kind char(8) not null,
credit float not null,
credit1 decimal(2,1) not null,
teacher varchar(20) not null,
departno varchar(2) not null,
schooltime char(10) not null,
limitnum int not null,
willnum int not null,
choosenum int not null)

三,打开数据库
use 数据库
use student
四.删除表
drop table 表名
drop table 学生信息

posted @ 2017-09-26 14:21  tcam  阅读(175)  评论(0编辑  收藏  举报