資料庫基本語句學習

2021-10-03 04:43:23 字數 1516 閱讀 7198

關係型資料庫:(relational)儲存資料在使用關係相互鏈結的表中,每個表儲存有關特定型別物件的資料。

非關係型資料庫:(nosql)沒有表和關係,不懂sql,他們有自己的語言系統。

大小寫功效相同。

use sql_store  //使用某個表

select *//檢索所有列

from customers //從某個表中

where customer_id=1  //條件語句

order by first_name  //排序

select last_name,first_name,points+10  //+-*/等算術表示式可以被使用,用來新建乙個列

//按順序排列,最好加上()便於理解

select points*10+100 as 『discount_factor』

在工作台下方資料表中可以更改資料,但要按鍵儲存

select distinct state //消除重複

字串要加『』或者「」

>,<,>=,<=

where birth_date > 『1990-09-09』 

where birth_date > 『1990-09-09』 and / or points>1000

where not (birth_date > 『1990-09-09』 and / or points>1000)

where state=』va』 or 『ga』 (error)

where state in (『va』,』ga』)  

where state not in (『va』,』ga』)

where points between 1000 and 2000

where last_name like 『b%』 //以b為首,不分大小寫,%表示任意數量字元

where last_name not like 『b%』 

where last_name like 『%b%』  //b在中間

where last_name like 『%b』  //b在末尾

where last_name like 『____b』 //固定位置和缺失位數

where last_name like 『b______y』

where last_name regexp 『field』  //含有此字串

where last_name regexp 『^field』  //以此字串開頭

where last_name regexp 『field%』  //以此字串結尾

where last_name regexp 『field|mac』  //或者

where last_name regexp 『field$|mac』

where last_name regexp 『[gim]e』 //含有字元ge/ie/me

where last_name regexp 『[a-h]e』 //ae be``````he

where phone is null

where phone is not null

資料庫基本語句

資料庫很久沒用,忘的差不多了,練習一下。環境 mysql 表1表名 test1 屬性 id name,bookid 表二表名 book 屬性 id,name 1.建立資料庫 create database study1 2.建立表 create table test1 id int 11 not n...

資料庫基本語句

ddl 資料庫或者表的結構 建立 create database table dbname tablename 修改 alter table tablename add modify change drop 列名 型別 約束條件 刪除 drop database table dbname table...

MYSQL資料庫基本語句

sqlite3支援的型別 整數,文字,浮點,二進位制 sqlite3 test.sqlite test.sqlite是資料庫的名字 table 檢視資料庫中是否有表 建立表 no學號 整型 主鍵 自動增長的 不能為空 name姓名 文字 不能為空 age年齡 整型 create table stud...