一個簡單的MySQL資料庫指令碼

來源:互聯網
上載者:User

                                                       一個簡單的MySQL資料庫指令碼

         這段時間因為項目需要學習了MySQL資料庫,貼一個關於建立資料庫,資料表,使用者的MySQL指令碼,和大家分享。

<br />--<br />--Create Database<br />--<br />create database if not exists new_db character set = 'gb2312' collate = 'gb2312_chinese_ci';<br />--<br />--Create Table<br />--<br />use new_db;<br />drop table if exists Customer;<br />create table Customer<br />(<br /> CustomerID smallint unsigned not null primary key auto_increment,<br /> Name varchar(20) not null,<br /> Gender ENUM('M', 'F') not null, /*M->Male, F->Female*/<br /> Address varchar(25) not null default ' ',<br /> Telephone smallint unsigned not null default '0'<br />)engine = InnoDB default charset = gb2312 default collate = gb2312_chinese_ci;<br />use new_db;<br />drop table if exists TestingInfo;<br />create table TestingInfo<br />(<br /> TestingID smallint unsigned primary key not null auto_increment,<br /> CustomerID smallint unsigned not null ,<br /> City varchar(20) not null default ' ',<br /> CurDate date not null default 0,<br /> CheckIn ENUM('T', 'N') not null, /*T->True, N->Not*/<br /> Groups ENUM('A', 'B', 'C') not null,<br /> foreign key (CustomerID) references Customer(CustomerID)<br />)engine = InnoDB default charset = gb2312 default collate = gb2312_chinese_ci;<br />--<br />--Creata user<br />--<br />use new_db;<br />grant select, insert, update, delete on new_db.* to m1@'%', m2@'%', m3@'%'; 

             具體的文法,可以參考MySQL的文檔。

     

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.