Home Database Mysql Tutorial J2EE 开发购物网站 经验篇

J2EE 开发购物网站 经验篇

Jun 01, 2016 pm 02:06 PM
varchar develop data database type experience website Shopping

J2EE

  
GO ON 继续进阶!!(本贴个人认为对初学者很有帮助,请大家认真看。因时间仓促,如有错误请指正)
SQL*PLUS基础
在上一贴中,我们掌握了些基本的oracle操作,如创建、授权用户,创建数据库等。在OEM(Oracle Enterprise Manager)可视化的窗口环境中,虽然我们也可以很方便地做这些事,但是事实上,用SQL语言书写在开发上更有效率!!oracle提供的SQL*Plus就是个不错的工具,如果大家喜欢窗口的开发环境,用SQLPlus Worksheet也行!下面说点基本的西西! SQL(Structure Query Language)语言是结构化查询语言,是数据库的核心语言,是面向集合的描述性非过程化语言。
SQL语言共分为四大类:数据查询语言DQL,数据操纵语言DML,数据定义语言DDL,数据库控制语言DCL。 1.数据查询语言DQL的基本结构是由select子句,from子句,where子句组成的查询块:
select from where 2.数据操纵语言DML完成在数据库中确定、修改、添加、删除某一数据值的任务(以下是部分常用DML语句):
insert    增加数据行到表
delete    从表中删除数据行
Update    更改表中数据 3.数据定义语言DDL完成定义数据库的结构,包括数据库本身、数据表、目录、视图等数据库元素(以下是部分常用DDL语句)
create table    创建表
create index    创建索引
create view    创建视图
alter table    增加表列,重定义表列,更改存储分配
drop table    删除表
drop index    删除索引 4.数据库控制语言DCL用来授予或回收访问数据库的某种特权,并控制数据库操纵事务发生的时间及效果,对数据库实行监视等。如:
grant        将权限或角色授予用户或其它角色
revoke        回收用户权限
roll        回滚,是当某个对话更改了数据库中的数据后,由于某种原因用户不想提交此更改时,oracle所采取的保护操作。这是一个把信息恢复到用户使update、insert、delete前最后提交的状态。
commit        提交。在完成数据库的插入,删除和修改操作时,只有当事务提交到数据库才算完成,有提交前只有操作数据库的本人才能看到,别人只有在最后提交完成才可以看到。 接下来,我们在SQL*Plus中实战一下,为我们下面将要做的打好基础。
用system登陆到SQL*Plus后,我们做如下操作(这次没有截图,有详细的说明)
SQL>create user maxuan identified by max; #创建口令为max的用户maxuan
SQL>grant connect,resource to maxuan; #为用户maxuan授权
SQL>conn maxuan/max; #以用户maxuan进行连接
L>create table test(a number); #建立一个名为test的表,只有字段名为A的一列,数据类型为数字
SQL>insert into test values(1); #插入一条记录
SQL>select * from test; #查询记录,此时A列的第一行为1
SQL>update test set a=2; #更改记录,此时A列的第一行已改为2
SQL>commit; #提交
SQL>delete from test; #删除test表中所有的记录,此时test表中没有记录
SQL>roll; #回滚到提交前,此时再查询test表,A列第一行值又回复到2 oracle的数据类型
在数据库中创建数据表的时候,我们需要定义表中所有字段的类型,数据类型大致分为:character,numberic,date,lob和raw等,这些是最基本的数据类型。当然在oracle中也允许自定义数据类型! 在oracle中提供的character数据类型:
char():固定长度字符串,最大长度为2000字节,如果不指定长充,缺省为1个字节长。
varchar2():可变长度的字符串,最大长度为4000字节,具体定义时指明最大长度,这咱类型可以放数字、字母以及ASCII码字符集(或者EBCDIC等数据库系统接受的字符集标准)中的所有符号。如果数据长度没有达到最大值,oracle会根据数据大小自动调节字段长度。是 最长用的数据类型。
nchar():根据字符集而定的固定长度字符串,最大长度2000字节。
nvarchar2():根据字符集而定的可变长度字符串,最大长度4000字节。
long:可变长字符列,最大长度限制为2GB,用于不需要作字符串搜索的长串数据。此类型是一个遗留下来的而且将来不会被支持的数据类型,逐渐被BLOB,CLOB,NCLOB等大的数据类型所取代。 numberic数据类型用来存储负的和正的整数,分数和浮点型数据,在oracle中提供的numberic数据类型:
number(,):可变长的数值列,允许0、正值及负值,m是所有的有效数字的位数,n是小数点以后的位数。 在oracle中提供的date数据类型:
date:缺省格式是dd-mon-yy(日-月-年) 在oracle中提供的lob数据类型:
blob、clob、nclob:三种大型对象(lob),用来保存较大的图形文件或带格式的文本文件,如word文档,以及音频、视频等非文本文件,最大长充是4GB。晕些数据存储在数据库内部保存。
bfile:在数据库外部保存的大型二进制对象文件,最大长度是4GB,这种外部的LOB类型,通过数据库记录变化情况,但是数据的具体保存是在数据库外部进行的。 在oracle中提供的raw数据类型:
raw():可变长二进制数据,具体定义字段时必须指明最大长度,这种格式用来保存较小的图形文件或带格式的文本文件,它也是一种较老的数据类型,将被lob数据类型所取代。
long raw:可变长二进制数据,最大长度是2GB,可以用来保存较大的图形或带格式的文本文件,以及音频、视频等非文本文件,这也是一种较老的数据类型,将被lob数据类型所取代。 其它的数据类型:
rowid:这是oracle数据表中的一个伪例,它是数据表中每行数据内在的唯一标识
integer:整数类型
创建购物网站后台数据库 现在我们回到用J2EE体系开发购物网站的主题,开始实战建购物网站的后台数据库。
为了实现购物网站的基本的功能,我们需要建立四个表:商品列表(products)、商品类型表(item)、订单列表(orders)和管理员列表(admin)。表结构如下所示: item表结构(商品类型表)
字段名称    数据类型        允许空    主键/外键    备注   
type_id    INTEGER(自动编号)    否    主键    商品类别ID标记
type    varchar2(30)    否        商品类别名称 product表结构(商品列表)
字段名称    数据类型        允许空    主键/外键    备注
product_id    INTEGER(自动编号)    否    主键    商品ID标记
title    varchar2(30)    否        商品名称
type_id    INTEGER        否    外键    商品类别标记
info    varchar2(80)    是        商品简介
price    number(16,2)    否        商品价格 orders表结构(订单列表)
字段名称    数据类型        允许空    主键/外键    备注
order_id    INTEGER(自动编号)    否    主键    订单ID标记
name    varchar2(20)    否        顾客姓名
address    varchar2(100)    是        发货地址
tel    number(16)    是        联系电话
email    varchar2(30)    否        联系email
btime    date        是        订购日期
product_id    INTEGER        否    外键    商品标记
uword    varchar2(100)    是        顾客留言 admin表结构(管理员列表)
字段名称    数据类型        允许空    主键/外键    备注
admin_id    INTEGER(自动编号)    否    主键    管理员ID标记
adminname    varchar2(20)    否        管理员名称
password    varchar2(20)    否        管理员密码 设计完表结构后,我们就要开始创建了。
创建表我想已经不是什么难事了,那么我们要注意的是product、item、orders这三个表之间的关联,还有自动编号。 下面是完整的SQL语句,在后面我会给出详细的说明,你可以在SQL*Plus里对照着输入,也可以将它存为SQL脚本文件,在SQL*Plus或SQLPlus Worksheet里执行。当然也可以把代码直接拷贝到SQL*Plus里执行! 代码拷贝框
rem ///BY MAXUAN 开始/// create table item( type_id integer not null, type varchar2(30), constraint item_pk primary key(type_id) ); create table product( product_id integer not null, title varchar2(30) not null, type_id integer not null, info varchar2(80), price number(16,2) not null, constraint product_pk primary key (product_id), constraint product_fk foreign key(type_id) references item(type_id) ); create table orders( order_id integer not null, name varchar2(20) not null, address varchar2(100), tel number(16), email varchar2(30) not null, btime date, product_id integer not null, uword varchar2(100), constraint orders_pk primary key(order_id), constraint orders_fk foreign key(product_id) references product(product_id) ); create table admin( admin_id integer not null, adminname varchar2(20) not null, password varchar2(20) not null, constraint admin_pk primary key(admin_id) ); create sequence type_id increment by 1 start with 1; create sequence product_id increment by 1 start with 1; create sequence order_id increment by 1 start with 1; create sequence admin_id increment by 1 start with 1; rem ///BY MAXUAN 结束///
[Ctrl+A 全部选择 然后拷贝] 说明一:建立表之间的关联
product、item、orders三个表通过公共域,通常称为键域(Key Field)进行关联,存在两种类型的键:主键(Primary key)和外部键(Foreign key)。主键使表中的数据行保持唯一,在表product中,product_id为主键,表orders中也包含有product_id,此时的product_id就是外部键。一个表的外部键从其它表中获取信息。看看上面的SQL语句,应该会了吧! 说明二:关于自动编号
在access中有自动编号的数据类型,MSSQL和MYSQL也都有自动增长的数据类型,插入记录时不用操作此字段,会自动获得数据值,而oracle没有自动增长的数据类型,我们需要建立一个自动增长的序列号,插入记录时要把序列号的下一个值赋于此字段,可以预见的是,有此功能,我们可以把数据从ACCESS、MSSQL或MYSQL迁移到oracle了!
create sequence type_id increment by 1 start with 1;
这句中,type_id为序列号的名称,每次增长为1,起始序号为1。 好了,咱们的数据库已经建好了,而且从中也了解到一些基本的相关知识,关于本人的用J2EE开发购物网站之二oracle篇到此结束,如有什么疑问请留言!!
在接下的第三篇weblogic中,本人将继续把个人心血经验无偿奉上,希望大家能从中有所收获!!谢谢支持!
PS:写得真累,快赶上出书了!!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks Apr 29, 2024 pm 06:55 PM

I cry to death. The world is madly building big models. The data on the Internet is not enough. It is not enough at all. The training model looks like "The Hunger Games", and AI researchers around the world are worrying about how to feed these data voracious eaters. This problem is particularly prominent in multi-modal tasks. At a time when nothing could be done, a start-up team from the Department of Renmin University of China used its own new model to become the first in China to make "model-generated data feed itself" a reality. Moreover, it is a two-pronged approach on the understanding side and the generation side. Both sides can generate high-quality, multi-modal new data and provide data feedback to the model itself. What is a model? Awaker 1.0, a large multi-modal model that just appeared on the Zhongguancun Forum. Who is the team? Sophon engine. Founded by Gao Yizhao, a doctoral student at Renmin University’s Hillhouse School of Artificial Intelligence.

Slow Cellular Data Internet Speeds on iPhone: Fixes Slow Cellular Data Internet Speeds on iPhone: Fixes May 03, 2024 pm 09:01 PM

Facing lag, slow mobile data connection on iPhone? Typically, the strength of cellular internet on your phone depends on several factors such as region, cellular network type, roaming type, etc. There are some things you can do to get a faster, more reliable cellular Internet connection. Fix 1 – Force Restart iPhone Sometimes, force restarting your device just resets a lot of things, including the cellular connection. Step 1 – Just press the volume up key once and release. Next, press the Volume Down key and release it again. Step 2 – The next part of the process is to hold the button on the right side. Let the iPhone finish restarting. Enable cellular data and check network speed. Check again Fix 2 – Change data mode While 5G offers better network speeds, it works better when the signal is weaker

The U.S. Air Force showcases its first AI fighter jet with high profile! The minister personally conducted the test drive without interfering during the whole process, and 100,000 lines of code were tested for 21 times. The U.S. Air Force showcases its first AI fighter jet with high profile! The minister personally conducted the test drive without interfering during the whole process, and 100,000 lines of code were tested for 21 times. May 07, 2024 pm 05:00 PM

Recently, the military circle has been overwhelmed by the news: US military fighter jets can now complete fully automatic air combat using AI. Yes, just recently, the US military’s AI fighter jet was made public for the first time and the mystery was unveiled. The full name of this fighter is the Variable Stability Simulator Test Aircraft (VISTA). It was personally flown by the Secretary of the US Air Force to simulate a one-on-one air battle. On May 2, U.S. Air Force Secretary Frank Kendall took off in an X-62AVISTA at Edwards Air Force Base. Note that during the one-hour flight, all flight actions were completed autonomously by AI! Kendall said - "For the past few decades, we have been thinking about the unlimited potential of autonomous air-to-air combat, but it has always seemed out of reach." However now,

Tesla robots work in factories, Musk: The degree of freedom of hands will reach 22 this year! Tesla robots work in factories, Musk: The degree of freedom of hands will reach 22 this year! May 06, 2024 pm 04:13 PM

The latest video of Tesla's robot Optimus is released, and it can already work in the factory. At normal speed, it sorts batteries (Tesla's 4680 batteries) like this: The official also released what it looks like at 20x speed - on a small "workstation", picking and picking and picking: This time it is released One of the highlights of the video is that Optimus completes this work in the factory, completely autonomously, without human intervention throughout the process. And from the perspective of Optimus, it can also pick up and place the crooked battery, focusing on automatic error correction: Regarding Optimus's hand, NVIDIA scientist Jim Fan gave a high evaluation: Optimus's hand is the world's five-fingered robot. One of the most dexterous. Its hands are not only tactile

Single card running Llama 70B is faster than dual card, Microsoft forced FP6 into A100 | Open source Single card running Llama 70B is faster than dual card, Microsoft forced FP6 into A100 | Open source Apr 29, 2024 pm 04:55 PM

FP8 and lower floating point quantification precision are no longer the "patent" of H100! Lao Huang wanted everyone to use INT8/INT4, and the Microsoft DeepSpeed ​​team started running FP6 on A100 without official support from NVIDIA. Test results show that the new method TC-FPx's FP6 quantization on A100 is close to or occasionally faster than INT4, and has higher accuracy than the latter. On top of this, there is also end-to-end large model support, which has been open sourced and integrated into deep learning inference frameworks such as DeepSpeed. This result also has an immediate effect on accelerating large models - under this framework, using a single card to run Llama, the throughput is 2.65 times higher than that of dual cards. one

Open-Sora comprehensive open source upgrade: supports 16s video generation and 720p resolution Open-Sora comprehensive open source upgrade: supports 16s video generation and 720p resolution Apr 25, 2024 pm 02:55 PM

Open-Sora has been quietly updated in the open source community. It now supports video generation up to 16 seconds, with resolutions up to 720p, and can handle text-to-image, text-to-video, image-to-video, and video-to-video of any aspect ratio. and the generation needs of infinitely long videos. Let's try it out. Generate a horizontal screen Christmas snow scene, post to B site and then generate a vertical screen, and use Douyin to generate a 16-second long video. Now everyone can have a screenwriting addiction. How to play? Guidance GitHub: https://github.com/hpcaitech/Open-Sora What’s even cooler is that Open-Sora is still all open source, including the latest model architecture, the latest model weights, multi-time/resolution/long-term

Within hours of release, Microsoft deleted a large open source model comparable to GPT-4 in seconds! Forgot to take the poison test Within hours of release, Microsoft deleted a large open source model comparable to GPT-4 in seconds! Forgot to take the poison test Apr 23, 2024 pm 05:22 PM

Last week, Microsoft airdropped WizardLM-2, an open source model called GPT-4 level. But I didn’t expect that it would be deleted immediately a few hours after it was posted. Some netizens suddenly discovered that WizardLM’s model weights and announcement posts had all been deleted and were no longer in the Microsoft collection. Apart from the mention of the site, no evidence could be found to prove that this was an official Microsoft project. The GitHub project homepage has become a 404. Project address: https://wizardlm.github.io/ Including the weight of the model on HF, all have disappeared... The whole network is full of confusion, why is WizardLM gone? However, the reason Microsoft did this was because the team forgot to "test" the model. Later, micro

70B model generates 1,000 tokens in seconds, code rewriting surpasses GPT-4o, from the Cursor team, a code artifact invested by OpenAI 70B model generates 1,000 tokens in seconds, code rewriting surpasses GPT-4o, from the Cursor team, a code artifact invested by OpenAI Jun 13, 2024 pm 03:47 PM

70B model, 1000 tokens can be generated in seconds, which translates into nearly 4000 characters! The researchers fine-tuned Llama3 and introduced an acceleration algorithm. Compared with the native version, the speed is 13 times faster! Not only is it fast, its performance on code rewriting tasks even surpasses GPT-4o. This achievement comes from anysphere, the team behind the popular AI programming artifact Cursor, and OpenAI also participated in the investment. You must know that on Groq, a well-known fast inference acceleration framework, the inference speed of 70BLlama3 is only more than 300 tokens per second. With the speed of Cursor, it can be said that it achieves near-instant complete code file editing. Some people call it a good guy, if you put Curs

See all articles