MySQL基本使用

來源:互聯網
上載者:User

標籤:命令   自動   content   基本   方式   create   不能   lock   use   

來自李興華視頻。

1. 啟動命令列方式

2. 串連mysql資料庫,其中“-u”標記的是輸入使用者名稱,“-p”標記的是輸入密碼。

3. 建立一個新資料庫——mldn,使用UTF-8編碼:

create database mldn character set utf8;

4. 查看所有資料庫:

show databases;

5. 使用mldn資料庫:

use mldn;

6. 建立資料表:

create table news(

  nid int auto_increment,

  title varchar(30) not null,

  content text,

  constraint pk_nid primary key(nid)

)engine = innodb;

在MySQL裡面不能再去使用number、varchar2了,只能夠用int、double、text、varchar類型,其中auto_increment表示nid的列將採用自動成長的方式進行,而最後加上的“engine=innodb”,表示此表支援事物處理功能。

範例:增加資料

insert into news(title, content) values ("wangke", "wangyan.");

7. 如果在MySQL之中取的增長後的主鍵使用如下文法:

 

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.