SQL語法基礎

2021-09-02 03:35:41 字數 1210 閱讀 1259

--建立使用者 使用者名稱:gome 密碼:gome  

create user gome identified by gome;

create user gome identified by gome;

--授權

--sys使用者是資料庫管理系統的許可權,包括底層的資料庫軟體,system是資料庫例項的許可權,

--最大的區別就是要建立例項,只能用sys使用者。一般情況下dba角色的許可權相當於system

grant dba to gome;

grant dba to gome;

--刪除使用者

drop user gome;

drop user gome;

--如果已有資料,這樣刪除使用者

drop user gome cascade;

drop user gome cascade;

--刪除表

drop table consumer

--建立表 consumer

create table consumer(

id int not null primary key,

name varchar(30) not null,

age int not null,

*** varchar(2) not null,

birthday date

);/*

在瀏覽器選擇 my objects 可以看到只屬於自己的東西,要不然得看到系統提供的其他資料,

這樣看起來非常麻煩

*/--檢視資料

select id, name, age, ***, birthday from consumer

--插入資料

insert into consumer

(id, name, age, ***, birthday)

values

(1, 'chaoyi', 30, '男', sysdate);

--刪除資料

delete consumer where id = 1;

--修改資料

update consumer

set id = 17,

name = 'chaoyv',

age = 31,

*** = '男',

birthday = sysdate

where id = 1;

SQL基礎語法

select 語句用於從表中選取資料。結果被儲存在乙個結果表中 稱為結果集 select 列名稱 from 表名稱select from 表名稱如需獲取名為 lastname 和 firstname 的列的內容 從名為 persons 的資料庫表 請使用類似這樣的 select 語句 select ...

SQl基礎語法

1 ddl data define language 01.用來建立和刪除儲存資料的資料庫以及表等物件。create 建立資料庫或者表 create table a create database a drop 用來刪除表或者資料庫,刪除後無法恢復。drop table a drop databas...

SQL語法基礎

建立使用者 使用者名稱 gome 密碼 gome create user gome identified by gome create user gome identified by gome 授權 sys使用者是資料庫管理系統的許可權,包括底層的資料庫軟體,system是資料庫例項的許可權,最大的...