資料庫開發 MySQL

來源:互聯網
上載者:User

標籤:

MySQL是Web世界中使用最廣泛的資料庫伺服器。SQLite的特點是輕量級、可嵌入,但不能承受高並發訪問,適合案頭和行動裝置 App。而MySQL是為伺服器端設計的資料庫,能承受高並發訪問,同時佔用的記憶體也遠遠大於SQLite。

此外,MySQL內部有多種資料庫引擎,最常用的引擎是支援資料庫事務的InnoDB。

設定mysql root帳號密碼

mysql admin -u root password root
修改root密碼
mysql admin -u root -p password newpwd
串連資料庫
mysql -u root -pmysql -u root -p root
串連遠程主機mysql
mysql -h 主機地址 -u 使用者名稱 -p 使用者密碼
建立資料庫
create database mydb;
設定字元集
alter database mydb default character set = utf8;
顯示資料庫列表
show databases;
切換到某個database
use mydb;

顯示本庫中的所有表

show tables;

顯示某表(table1)的結構

describe table1;

建庫

create database

建表

create table tableName (欄位設定列表);

刪庫

drop database 庫名;

刪表

drap table 表名;

將表中的記錄清空

delete from 表名;

為已經存在的表添加新列

alter table tableName add newColumn varchar(8) comment ‘新添加的欄位‘ // comment為注釋,就像在java中//作用是一樣的。

為列設定預設值

create table tablename (columnname datatype default defaultvalue); // 建立並設定預設值alter table tablename alter column columnname set default defaultvalue; // 修改現有列的預設值

刪除列

alter table tableName drop column Gatewayid

 

 

  

資料庫開發 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.