直接用命令建表,这个在哪个数据库中都可以不管是SQL SERVER,ORACLE还是MYSQL。 create table xxxx (id int, f1 char(10));你所指的是SQL SERVER的另外的管理器吧,这个对于MYSQL官方提供了一个WORKBENCH,你可以单独到MYSQL官网下载。已回答,详细你可以查看MYSQL手册中的语法和例子。
// 删除test数据库 drop database test; // 创建数据库 create database test;//使用数据库 use test;//创建表create table member( id int(20) not null primary key, password varchar(200) not null ); // 在表中插入一条数据 insert into member(id,password) values(11,"123");select * from member;
create database test; use test; create table test( id int not null primary key, name varchar(20) //注意此处不要加标点 );
DROP TABLE IF EXISTS `t_class`; CREATE TABLE `t_class` ( `Id` int(11) unsigned NOT NULL auto_increment COMMENT '主键ID', `name` varchar(100) NOT NULL default '' COMMENT '班级名称', `classTacherID` int(11) NOT NULL default '0' COMMENT '班主任外键ID', `departmentID` int(11) NOT NULL default '0' COMMENT '外键ID,所在系表ID', `trainingLevel` int(11) NOT NULL default '0' COMMENT '外键ID,培养层次表ID', `professional` int(11) NOT NULL default '0' COMMENT '外键ID,对应专业表主键', `learningStyle` int(11) NOT NULL default '0' COMMENT '学习形式1普通全日制,2委培。', `classshifoubiye` int(11) unsigned default '0' COMMENT '班级是否已经毕业 0表示未毕业 1表示已经毕业', PRIMARY KEY (`Id`) ) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8 COMMENT='表-7班级表';
use master go--创建数据库 if exists (select * from sysdatabases where name='表名') drop database 表名 gocreate database 表名 on primary ( name='表名_data', filename='D:\路径\表名_data.mdf', size=5mb, filegrowth=15% ) log on ( name='表名_log', filename='D:\路径\表名_log.ldf' ) go--建表 use 表名 goif exists(select * from sysobjects where name='DiaryInfo') drop table DiaryInfo go create table DiaryInfo ( ID int identity(1,1) primary key, Author varchar(20) not null, Title nvarchar(50) not null, Contents nvarchar(500) not null, CreateTime datetime not null ) go--建立约束 alter table DiaryInfo add constraint CK_Contents check (len(Contents) >=10), constraint DF_CreateTime default (getdate()) for CreateTime go --插入数据 insert into DiaryInfo (Author,Title,Contents) values ('张三','今天考试啦','及格啊!及格!给个及格!谢谢啦!') --测试查询 select * from DiaryInfo
create table xxxx (id int, f1 char(10));你所指的是SQL SERVER的另外的管理器吧,这个对于MYSQL官方提供了一个WORKBENCH,你可以单独到MYSQL官网下载。已回答,详细你可以查看MYSQL手册中的语法和例子。
CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name
[create_specification ...]create_specification:
[DEFAULT] CHARACTER SET charset_name
| [DEFAULT] COLLATE collation_nameCREATE DATABASE CSDN
CREATE TABLE t1 (col1 INT, col2 CHAR(5))有和sql server一样的操作界面吗?哪一个是SQLYOG mysql front还有命令行建库建表如何操作?
mysql> CREATE DATABASE CSDN;
Query OK, 1 row affected (0.01 sec)mysql> USE CSDN;
Database changed
mysql> CREATE TABLE t1 (col1 INT, col2 CHAR(5));
Query OK, 0 rows affected (0.06 sec)mysql>
推荐使用 HeidiSQL
http://download.csdn.net/source/1947825
drop database test; // 创建数据库
create database test;//使用数据库
use test;//创建表create table member(
id int(20) not null primary key,
password varchar(200) not null
);
// 在表中插入一条数据
insert into member(id,password) values(11,"123");select * from member;
use test;
create table test(
id int not null primary key,
name varchar(20) //注意此处不要加标点
);
CREATE TABLE `t_class` (
`Id` int(11) unsigned NOT NULL auto_increment COMMENT '主键ID',
`name` varchar(100) NOT NULL default '' COMMENT '班级名称',
`classTacherID` int(11) NOT NULL default '0' COMMENT '班主任外键ID',
`departmentID` int(11) NOT NULL default '0' COMMENT '外键ID,所在系表ID',
`trainingLevel` int(11) NOT NULL default '0' COMMENT '外键ID,培养层次表ID',
`professional` int(11) NOT NULL default '0' COMMENT '外键ID,对应专业表主键',
`learningStyle` int(11) NOT NULL default '0' COMMENT '学习形式1普通全日制,2委培。',
`classshifoubiye` int(11) unsigned default '0' COMMENT '班级是否已经毕业 0表示未毕业 1表示已经毕业',
PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8 COMMENT='表-7班级表';
http://www.heidisql.com/
go--创建数据库
if exists (select * from sysdatabases where name='表名')
drop database 表名
gocreate database 表名
on primary
(
name='表名_data',
filename='D:\路径\表名_data.mdf',
size=5mb,
filegrowth=15%
)
log on
(
name='表名_log',
filename='D:\路径\表名_log.ldf'
)
go--建表
use 表名
goif exists(select * from sysobjects where name='DiaryInfo')
drop table DiaryInfo
go
create table DiaryInfo
(
ID int identity(1,1) primary key,
Author varchar(20) not null,
Title nvarchar(50) not null,
Contents nvarchar(500) not null,
CreateTime datetime not null
)
go--建立约束
alter table DiaryInfo
add constraint CK_Contents check (len(Contents) >=10),
constraint DF_CreateTime default (getdate()) for CreateTime
go
--插入数据
insert into DiaryInfo (Author,Title,Contents) values ('张三','今天考试啦','及格啊!及格!给个及格!谢谢啦!')
--测试查询
select * from DiaryInfo