簡單的資料表操作

2021-07-02 22:28:06 字數 1085 閱讀 1003

簡單的資料表操作

--建立乙個簡單的表student

create table student(

stuid number(8),

stuname varchar2(20),

stuphone varchar2(12)

);--插入新記錄

insert into student (stuid,stuname,stuphone) values(1,'lisi','888888');--  完全插入  包括所有欄位名

insert into student values(2,'zhangsan','888888');   --  完全插入  省略所有欄位名

insert into student (stuid,stuname) values(3,'wangwu');  --部分插入    不可省略欄位名

--修改表中資料

update student set stuname='lili' where stuid=1; --修改表中stuid為1的stuname為lili;

--刪除表中資料

delete student where stuid=3;   --刪除一條記錄   刪除stuid為3的記錄

delete student;    --刪除表中所有記錄   注意的是表結構還在。

--檢視表結構

select * from student;   --檢視表中所有記錄及表結構

--刪除表

drop table student;   --刪除表中的資料及表結構   用該關鍵字刪除,那麼該錶在資料庫中就不存在了。

資料表的操作

表是組成資料庫的基本的元素 表的基本操作有 建立 檢視 更新 刪除。表中的資料庫物件包含列 索引 觸發器。列 屬性列,建立表時指定的名字和資料型別,索引 根據制定的資料庫表建立起來的順序,提供了快速訪問資料的途徑且可以監督表的資料 觸發器 指使用者定義的事務命令集合,當對乙個表中的資料進行插入 更行...

資料表的操作

1.顯示所有的資料表 mysql show tables from 資料庫名 2.顯示表結構 mysql desc 表名 或者 describe 表名 3.顯示資料表建立語句 mysql show create table 表名 mysql show create table 表名 g 可以更清晰的...

資料表操作

1 建立資料表 create table if not exists table name column name data type,2 檢視資料表 show tables show tables from mysql 3 檢視資料表結構 show columns from tbl name 4 ...