1、运行Navicat数据库管理工具,连接本地数据库。点击左上角“文件”或者工具栏“连接”图标,创建自己的数据库连接。Navicat for MySQL可以连接本地Mysql数据库,还可以连接远程Mysql数据库。两者连接方式基本相同。
‘贰’ 设计题 有一个MySQL数据库store,在store数据库中含有一个销售表sale,用于存放商品的销售记录。
use store;
createtable sale(idintauto_incrementprimarykey,pm varchar(30) ,price decimal(9,2),num int,sum decimal(11,2));
insert into sale(pm,price,num) values ('电视机',1400.00,4);
select * from sale;
update sale set sum = 0 ;
select * from sale where price > 4000.00 order by sum desc
method = "post"
action = "calc_multi.php"
a
b
c
submit
...
‘叁’ 用SQL语句创表
CREATE TABLE S
(MNO VARCHAR2(10) PRIMARY KEY,
PNO VARCHAR2(10),
QTY NUMBER(20) NOT NULL);
用外码得用引用另一个表。
‘肆’ 在数据库中创建一张销售表,求代码就好 谢谢
创建表:create table ods_sales_detail(
订单号 varchar2(11),
订单日期 date,
组织编码 clob,
销售量 number,
销售单价 number
);
插入数据:
insert into ods_sales_detail('订单号',订单日期,'组织编码',销售量,销售单价) values('11022346220','2016-1-10','511',100000,1.89);
‘伍’ 数据库SQL的建表问题!
-- 1、 在销售商品的同时,将记录库存中该商品数量减少多少。
CREATE TRIGGER tg_receNO
ON sales FOR update
AS
begin
declare @oldnum int
declare @newnum int
set @oldnum=(select sale_number from deleted)
set @newnum=(select sale_number from inserted)
update stock set stock_number=stock_number-(@newnum-@oldnum)
--@newnum-@oldnum表示商品减少的数量
where dbo.stock.pro_id=(select pro_id from inserted)
end
‘陆’ 如何在数据库中创建表
以下为创建MySQL数据表的SQL通用语法:
CREATE TABLE table_name (column_name column_type);
以下例子中我们将在 RUNOOB 数据库中创建数据表runoob_tbl:
CREATE TABLE IF NOT EXISTS `runoob_tbl`(
`runoob_id` INT UNSIGNED AUTO_INCREMENT,
`runoob_title` VARCHAR(100) NOT NULL,
`runoob_author` VARCHAR(40) NOT NULL,
`submission_date` DATE,
PRIMARY KEY ( `runoob_id` )
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
实例解析:
如果你不想字段为 NULL 可以设置字段的属性为 NOT NULL, 在操作数据库时如果输入该字段的数据为NULL ,就会报错。
AUTO_INCREMENT定义列为自增的属性,一般用于主键,数值会自动加1。
PRIMARY KEY关键字用于定义列为主键。 您可以使用多列来定义主键,列间以逗号分隔。
ENGINE 设置存储引擎,CHARSET 设置编码。
‘柒’ 用create table语句 在数据库中建立销售表xsb.dbf,其结构和记录如下:
if(select count(*) from sysobjects where name = 'xsb') > 0
drop table xsb
go
create table xsb
(
销售日期 char(4) not null ,
商品号 char(4) not null ,
进货量 numeric(7,0) not null ,
销售量 numeric(7,0) not null ,
销售价 decimal(8,2) not null ,
库存量 numeric(8,0) not null ,
)
go
‘捌’ 数据库创建一个销售表的带参数的存储过程
你这是要创建表呢还是创建存储过程呢?
如果是创建表的话,
CREATE TABLE 销售表(
销售编号 类型,
商品编号 类型,
销售价格 类型,
销售数量 类型,
销售日期 类型
);
如果是要创建一个带入参的存储过程,基本语法为:
CREATE OR REPLACE PROCEDURE P_TEST1(PARM IN VARCHAR2)
BEGIN
END;
‘玖’ 以下信息,,用T-SQL语言创建表
create database sale
go
use sale
go
create table g(
商品号 int primary key,
商品名 char(20) not null,
单价 decimal(9,2)
)
go
create table s(
商店号 int primary key ,
商店名 char(20) not null,
经理 char(8)
)
go
create table gs(
商店号 int not null,
商品号 int not null,
销售量 int default(0)
)
go
alter table gs add constraint pk_store primary key(商店号,商品号)
go