Answer the question
In order to leave comments, you need to log in
How to change ms sql query to work on postgresql?
Hello, how should I rewrite the query
to ms sql I had
CREATE TABLE dbo.Salary(
Salary_data int NOT NULL,
Salary_date datetime NOT NULL)
GO
ALTER TABLE Salary
ADD CONSTRAINT DF_Salary_Salary_date DEFAULT (getdate()) FOR Salary_date
GO
ALTER TABLE Salary
ADD Employee_ID int NOT NULL
GO
ALTER TABLE Salary
WITH CHECK ADD CONSTRAINT FK_Salary_Employee_ID FOREIGN KEY(Employee_ID)
REFERENCES EMPLOYEE(Employee_ID)
ON UPDATE CASCADE
ON DELETE CASCADE
CREATE TABLE salary
(
employee_id integer NOT NULL,
salary_data integer NOT NULL,
salary_date date NOT NULL
);
ALTER TABLE salary
ADD CONSTRAINT DF_Salary_Salary_date DEFAULT (current_date) FOR salary_date;
ALTER TABLE salary
WITH CHECK ADD CONSTRAINT FK_Salary_Employee_ID FOREIGN KEY(employee_id)
REFERENCES EMPLOYEE(employee_id)
ON UPDATE CASCADE
ON DELETE CASCADE
Answer the question
In order to leave comments, you need to log in
did you try to see how to add default value, constraint, foreign key to the doc?
ALTER TABLE salary ALTER COLUMN salary_date SET DEFAULT current_date;
ALTER TABLE salary
ADD CONSTRAINT FK_Salary_Employee_ID FOREIGN KEY(employee_id)
REFERENCES EMPLOYEE(employee_id)
ON UPDATE CASCADE
ON DELETE CASCADE
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question