我想使用一個在線的MYSQL數據庫,主要通過桌面和手機應用程序訪問。我希望某人請快速查看我的代碼,並告訴我需要在安全性方面改變/改進哪些內容。基本上,我的代碼是可以改進還是應該改變?SQL代碼安全
這裏是我的代碼:
Create Database db_person_cdtest;
USE [db_person_cdtest]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [Person](
[PersonID] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
[ID] [varchar](20),
[FirstName] [varchar](50) NOT NULL,
[LastName] [varchar](50) NOT NULL,
[AddressLine1] [varchar](50),
[AddressLine2] [varchar](50),
[AddressLine3] [varchar](50),
[MobilePhone] [varchar](20),
[HomePhone] [varchar](20),
[Description] [varchar](10),
[DateModified] [datetime],
[PersonCategory] [varchar](30) NOT NULL,
[Comment] [varchar](max),
CONSTRAINT [PK_Person] PRIMARY KEY CLUSTERED
(
[PersonID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY];
CREATE PROCEDURE usp_InsertPerson
(
@ID VARCHAR(20),
@FirstName VARCHAR(50),
@LastName VARCHAR(50),
@AddressLine1 VARCHAR(50),
@AddressLine2 VARCHAR(50),
@AddressLine3 VARCHAR(50),
@MobilePhone VARCHAR(20),
@HomePhone VARCHAR(20),
@Description VARCHAR(10),
@Comment VARCHAR(max)
)
AS
BEGIN
Declare @PersonCategory VARCHAR(30)
SET @PersonCategory = dbo.usp_PersonCategoryLookup(@ID, @Description)
INSERT INTO Person(ID, FirstName, LastName, AddressLine1, AddressLine2, AddressLine3, MobilePhone, HomePhone, Description, DateModified, PersonCategory, Comment)
VALUES (@ID, @FirstName, @LastName, @AddressLine1, @AddressLine2, @AddressLine3, @MobilePhone, @HomePhone, @Description, GETDATE(), @PersonCategory, @Comment)
END
CREATE PROCEDURE usp_UpdatePerson
(
@PersonID numeric(18, 0),
@ID VARCHAR(20),
@FirstName VARCHAR(50),
@LastName VARCHAR(50),
@AddressLine1 VARCHAR(50),
@AddressLine2 VARCHAR(50),
@AddressLine3 VARCHAR(50),
@MobilePhone VARCHAR(20),
@HomePhone VARCHAR(20),
@Description VARCHAR(10),
@Comment VARCHAR(max)
)
AS
BEGIN
Declare @PersonCategory VARCHAR(30)
SET @PersonCategory = dbo.usp_PersonCategoryLookup(@ID, @Description)
Update Person set [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], DateModified=GETDATE(), [email protected], [email protected] where [email protected]
END
CREATE PROCEDURE usp_SearchPerson
(
@SearchCriteria VARCHAR(50)
)
AS
BEGIN
Select * from Person where FirstName like @SearchCriteria or LastName like @SearchCriteria or PersonCategory like @SearchCriteria
END
CREATE PROCEDURE usp_SelectPerson
(
@PersonID numeric(18, 0)
)
AS
BEGIN
select * from Person where [email protected]
END
CREATE FUNCTION usp_PersonCategoryLookup
(
@ID VARCHAR(20),
@Description VARCHAR(10)
)
RETURNS VARCHAR(30)
AS
BEGIN
return @ID + @Description
END
如果您使用的是MySQL數據庫,爲什麼要使用SQL Server約定編寫代碼? –