- 58
- 0
- 约1.31万字
- 约 30页
- 2021-10-19 发布于福建
- 举报
上机 1
1、 安装 Mysql;
注意:设置超级用户密码的时候,统一设置为 1234
2、 进入 Mysql;
开始 -程序 -MySQL-MySQL Server 5.0-MySQL Command Line Client
3、 建立数据库 BANKxxx ;
create database BANKxxx; --xxx 为你的学号后三位
show databases; --验证是否建立成功
//命令必须在后面加分号否则出错 ,如果 show databases;打成了 show database;
的话 ,也会错误,错误如下:
正常情况下是如下:
4、 使用数据库 BANK ;
use BANKxxx; --使用数据库 BANK
show tables; --数据库中没有表
因为此时 BANK234 为空表。
5、 建 立 表 BRANCHxxx, CUSTOMERxxx, LOANxxx, BORROWERxxx,
ACCOUNTxxx, DEPOSITORxxx ;
Creating DataBase
Creating the Banking database:
Database Schema:
branch (branch_name, branch_city, assets)
customer (customer_name, customer_street, customer_city)
depositor (customer_name, account_number)
account (account_number, branch_name, balance)
borrower (customer_name, loan_number)
loan (loan_number, branch_name, amount)
Creating database Banking steps:
1) CREATE DATABASE Banking … (syntax lie on
DBMS)
2) Creating referenced tables(被参照关系 )
3) Creating referencing tables
4) Creating other object of database
Creating Tables
Creating Tables in the Banking database:
//Creating table customer in SQL
CREATE TABLE customer (
customer_name char(20),
customer_street char(30) NOT NULL,
customer_city char(30)
) ;
CREATE TABLE ACCOUNTxxx (
account_number char(10),
branch_name char(30) NOT NULL,
balance numeric(12.2),
PRIMARY KEY ( account_number),
FOREIGN KEY ( branch_name)
REFERENCES branch(branch_name),
CONSTRAINT chk_balance CHECK ( balance = 0 ) ) ;
// 注意此处必须保证表 branch 存在,如果不存在的话,先创建 branch表
吧,否则会报错如图 1,原因如下:
Integrity Constraints in Tables
Create tab
您可能关注的文档
最近下载
- 电子病历系统应用水平四级实证材料通用模板(基本项部分)(2022版).doc VIP
- 实施指南《GB_T37306.1-2019金属材料疲劳试验变幅疲劳试验第1部分:总则、试验方法和报告要求》实施指南.docx VIP
- 中药生产监督管理专门规定-培训.pptx VIP
- 大学在线开放课程建设实施方案.docx VIP
- 电子病历系统应用水平四级实证材料通用模板(选择项部分)(2024版).doc VIP
- 北师大版六年级数学下册第一单元《圆柱与圆锥》课件.pptx VIP
- PEP人教版小学英语四年级下册阅读理解练习36篇.pdf VIP
- 2025年云南省中考数学——26题二次函数降次幂精选题35道.docx VIP
- 《化妆品中凝血酸(氨甲环酸)的测定 高效液相色谱法》.pdf VIP
- 厂房建设投资估算表.xls VIP
原创力文档

文档评论(0)