VirtualDataTable.sql 818 B

12345678910111213141516171819202122232425262728293031323334
  1. create or replace function create_virtual_device_table() returns void as
  2. $$
  3. begin
  4. if not exists(select * from information_schema.tables
  5. where
  6. table_catalog = CURRENT_CATALOG and table_schema = CURRENT_SCHEMA
  7. and table_name = 'VirtualDevice') then
  8. CREATE TABLE "VirtualDevice"
  9. (
  10. "ID" serial NOT NULL,
  11. "ChamberID" text,
  12. "DeviceName" character varying,
  13. "State" integer,
  14. "LastModifyDate" timestamp without time zone,
  15. "FunctionBlock" text,
  16. CONSTRAINT "VirtualDevice_pkey" PRIMARY KEY ("ID" )
  17. )
  18. WITH (
  19. OIDS=TRUE
  20. );
  21. ALTER TABLE "VirtualDevice"
  22. OWNER TO postgres;
  23. GRANT ALL ON TABLE "VirtualDevice" TO postgres;
  24. GRANT ALL ON TABLE "VirtualDevice" TO promaxyuser;
  25. end if;
  26. end;
  27. $$
  28. language 'plpgsql';
  29. select create_virtual_device_table();