在MySql中使用命令创建数据库bank

在MySql中使用命令创建数据库bank,第1张

mysql>create database bank

Query OK, 1 row affected (0.00 sec)

mysql>use bank

Database changed

mysql>create table chuhu(chuhu_id int,chuhu_name varchar(20))

Query OK, 0 rows affected (0.05 sec)

mysql>insert into chuhu values(1,'张三')

Query OK, 1 row affected, 1 warning (0.02 sec)

mysql>insert into chuhu values(2,'李四')

Query OK, 1 row affected, 1 warning (0.00 sec)

mysql>commit

Query OK, 0 rows affected (0.00 sec)

mysql>insert into mysql.user(Host,User,Password) values("localhost","bank_admin",password("000000"))

Query OK, 1 row affected, 3 warnings (0.01 sec)

mysql>commit

Query OK, 0 rows affected (0.00 sec)

mysql>flush privileges

Query OK, 0 rows affected (0.05 sec)

mysql>grant select,update on bank.chuhu to bank_admin@localhost identified by '000000'

Query OK, 0 rows affected (0.00 sec)

mysql>flush privileges

Query OK, 0 rows affected (0.00 sec)

D:\mysql5.0\bin>mysql -ubank_admin -p

Enter password: ******

Welcome to the MySQL monitor. Commands end with or \g.

Your MySQL connection id is 2

Server version: 5.0.51b-community-nt MySQL Community Edition (GPL)

Type 'help' or '\h' for help. Type '\c' to clear the buffer.

mysql>use bank

Database changed

在创建完数据库的时候加个GO,然后再写创建表的语句

--创建bankDB数据库

CREATE DATABASE bankDB

ON

(

NAME = 'bankDB_data',

FILENAME = 'E:\2期sql指导学习\bankDB_data.mdf',

SIZE = 5,

MAXSIZE = 20,

FILEGROWTH = 10%

)

LOG ON

(

NAME = 'bankDB_log',

FILENAME = 'E:\2期sql指导学习\bankDB_log.ldf',

SIZE = 2,

MAXSIZE = 10,

FILEGROWTH = 10%

)

GO

创建表userInfo

CREATE TABLE userInfo

(

customerID INT IDENTITY(1,1) NOT NULL,

customerName VARCHAR(10) NOT NULL,

PID VARCHAR(18) NOT NULL,

telephone VARCHAR(13) NOT NULL,

address VARCHAR(40)

)


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/10040176.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-04
下一篇 2023-05-04

发表评论

登录后才能评论

评论列表(0条)

保存