SQL 方面基礎操作,主要針對資料庫方面的操作步驟

來源:互聯網
上載者:User

標籤:建立   刪除表   資料庫資料   系統管理權限   代碼   資料   區分大小寫   大型   name   

SQL 結構化查詢語言 (SQL)  適用於所有的SQL資料庫

  SQL  要求每條指令後末端 都要有分號(;),分好是標準方法,對伺服器相同請求中執行一條以上的sql語句。

最終目的: 實現對資料庫資料的  增 刪 改 查 等等。

1. 開啟資料庫(選擇資料庫)

use DBRAM 

 DBRAM  這是一個資料庫的名稱,我們要選擇某個資料庫,大型資料庫中有多個資料庫,也有多個不同的使用者系統管理權限。

 use(開啟/選擇) DBRAM(資料庫名稱)

 

2.  設定字元集 utf-8是使用最多的字元編碼

set names utf8

  設定資料庫只用的字元集

 set  names utf8

 

3. 常用命令(命令列中不區分大小寫,但是命令的代碼要協同一致)

   --- 查詢資料   select 

select * from table

select * from table(表名稱)           /table  表的稱謂

 

  --- 更新資料  update

update  tabale    set  id=‘‘, name=‘‘;

update table(表名)

set 更新(改變)某項資料 id 和name 都是欄位名。

 

   ---插入資料  insert into

 

insert into table (id,name) values (‘1‘,‘hah‘);

 insert into  table(表) (欄位1,欄位2) values (‘值1‘,‘值2‘)

 

   ---建立資料庫 create datebase DBRAM (資料庫名)

create datebase DBRAM

 

     -----修改資料庫 alter datebase DBRAM

alter datebase DBRAM

 

  ----建立新表 create tabale

create table

 

  ---變更(改變)表 alter table

alter table

 

  ---刪除表資料 dalete table

dalete table

 

      ---刪除表  drop table

drop table

 

   ---建立索引(搜尋鍵) create index

create index

 

  ---刪除索引  drop index

drop index

 

SQL 方面基礎操作,主要針對資料庫方面的操作步驟

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.