数据库表的创建与查询
生活随笔
收集整理的這篇文章主要介紹了
数据库表的创建与查询
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
目錄
1 引言.SQL的特點(diǎn):
2.任務(wù):
1.定義模式test1,text1,其中test1有兩張表,分別如下:(模式:schema)
2.刪除模式test1(cascade)
3.定義基本表
4.創(chuàng)建基本表table屬于test1
針對DateGrip這款軟件,我交你如何進(jìn)行上面答案的編程:
5.模式與表
6.修改基本表
?
1 引言.SQL的特點(diǎn):
1.綜合體一
2.高度非過程話
3.面向集合的操作方式
4.以同一總語法結(jié)構(gòu)提供多種使用方式
5.語言簡潔,易學(xué)易用
2.任務(wù):
1.定義模式test1,text1,其中test1有兩張表,分別如下:(模式:schema)
table1:
| 名字 | 類型 |
| name | char |
| age | char |
?
table2:
| 名字 | 類型 |
| lokk | int |
| ax | char |
?
2.刪除模式test1(cascade)
3.定義基本表
注:定義一個(gè)模式,就是建立一個(gè)數(shù)據(jù)庫的命名空間,一個(gè)框架。
| 名字 | 類型 | 約束條件 |
| sno | char | PRIMAPY KEY |
| SNAME | CHAR | UNIQUE |
4.創(chuàng)建基本表table屬于test1
table1:
| 名字 | 類型 |
| lokk | int |
| ax | char |
針對DateGrip這款軟件,我交你如何進(jìn)行上面答案的編程:
create schema text1; create schema test1; use text1; create table table1(name char(2) primary key ,age char(3) unicode ); create table table2(look int ); use test1; create table table1(lokk int,ax char(2) );以下就是最終答案了:
最后的刪除:
create schema text1; #創(chuàng)建模式 create schema test1; use text1; create table table1( #創(chuàng)建表name char(2) primary key ,age char(3) unicode ); create table table2(look int ); use test1; #更改模式 create table table1(lokk int,ax char(2) ); drop schema test1;#刪除模式 use text1;drop table table1; drop table table2; #刪除表?
?
?
5.模式與表
create table text1.sa(sname char(2) ); #test1是表名,sa是模式名6.修改基本表(alter)
1.向基本表sa中加入entrance 類型為date
2.將SNAME中字符類型改為int
3.增加sanme的約束條件
?
alter table sa add enterce int; #修改并增加alter table sa DROP sname;alter table sa add SNAME int;alter table sa ADD UNIQUE(SNAME);注意:不同的數(shù)據(jù)庫在SQL語句上會有點(diǎn)差異
?
總結(jié)
以上是生活随笔為你收集整理的数据库表的创建与查询的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【机器学习】SVM理论与python实践
- 下一篇: 并发编程-concurrent指南-原子