易截截图软件、单文件、免安装、纯绿色、仅160KB

Sql语句学习笔记(2) 创建数据表

use RetalDB--表示在数据库RetalDB中进行的操作
go
if exists (select * from sysobjects where name='tb_user')
 drop table tb_user
go
--创建客户表tb_user
create table tb_user
(
 user_id int primary key,--指定为主键时,此列默认为非空,指定过多个限制条件时不用“'”隔开
 user_name varchar(20) not null,
 user_point int not null,
)
--创建影碟类型表tb_MovieType
if exists (select *from sysobjects where name='tb_movie_type')
 drop table tb_movie_type
go
create table tb_movie_type
(
 type_id int primary key,--指定主键
 type_name varchar(20) not null,
 type_english_name varchar(20) not null
)
--创建影碟表
if exists (select * from sysobjects where name='tb_movie')
 drop table tb_movie
go
create table tb_movie
(
 movie_id int primary key,
 movie_name varchar(20) not null,
 movie_price float,
 movie_type_id int not null,
 movie_detail varchar(255)
 --添加外键约束
 constraint FK_movie_id foreign key(movie_type_id) references tb_movie_type(type_id)--引用影片类型表中的type_id字段
)
--创建租赁信息表
if exists (select * from sysobjects where name='tb_retal')
 drop table tb_retal
go
create table tb_retal
(
 id int identity(1,1) primary key,--信息编号
 user_id int not null,--外键,引用客户表中的主键user_id
 movie_id int not null, --外键,引用影片表中的movie_id 
 rent_time datetime not null  default(getdate()),--租出时间,以插入数据时的时间为默认值
 return_time datetime,--归还时间
 rent_fee float default(0)--租金
 
 constraint FK_user_id foreign key(user_id) references tb_user(user_id),
 constraint FK_movie_id foreign key(movie_id) references tb_movie(movie_id)
)
创建好的表如图所示:(后来为了保证tb_retal中数据的唯一性,将user_id,movie_id,rent_time这3个键设置成了联合主键,即同一个客户不可能在同一时间租了同一张影碟多次)


相关文档:

免安装Oracle客户端软件 使用pl/sql配置登陆

虽然这是我找到最详细的配置描述,但是尝试还是没有成功。
 
1.下载Oracle Client Package
.

http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/winsoft.html
下载
Instant
Client Package – Basic

(

标注
:All files
required to run OCI, OCCI, and JDBC-OC ......

sql server2005 rownum通用存储过程分页

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER   PROCEDURE [dbo].[sp_GetRecordfromPage]
@TableName varchar(350),        --表名
@Fields varchar(5000) = '*',    --字段名(全部字段为*)
@OrderField varchar(5000),   &nbs ......

转载“解决SQL SERVER 2005用sa登陆问题”

装sql 2005后对一些功能还不是很习惯,比如用sa登录数据库在很多地方都会用到,今天就sa登录数据库的一些修改与大家分享。
1.先用WINDOWS模式登陆,然后在数据库顶端右键属性;如图1-1:
2.在安全性下的WINDOWS模式改为SQL与WINDOWS模式,下面的登陆审核选项,选择为‘无’,点‘确定’;如图1-2:
3. ......

SQL SERVER数据类型与C#数据类型对照表

bigint 从 -2^63 (-9223372036854775808) 到 2^63-1 (9223372036854775807) 的整型数据(所有数字)。存储大小为 8 个字节。 Int64
int 从 -2^31 (-2,147,483,648) 到 2^31 - 1 (2,147,483,647) 的整型数据(所有数字)。存储大小为 4 个字节。int 的 SQL-92 同义字为 integer。 Int32
smallint 从 -2^15 (-32,768) 到 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号