mysql操作手册[整理].pdfVIP

  • 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

文档评论(0)

1亿VIP精品文档

相关文档