Guest User

Untitled

a guest
Jan 7th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. -- Set connection to execute ddl operations asynchronously and automatically in batches for better performance
  2. SET_CONNECTION_PROPERTY AsyncDdlOperations=true;
  3. SET_CONNECTION_PROPERTY AutoBatchDdlOperations=true;
  4.  
  5. CREATE TABLE customer (
  6. id INT64 NOT NULL,
  7. uuid BYTES(16) NOT NULL,
  8. created TIMESTAMP NOT NULL,
  9. updated TIMESTAMP NOT NULL,
  10. firstName STRING(50),
  11. lastName STRING(100) NOT NULL
  12. )
  13. PRIMARY KEY (id)
  14. ;
  15.  
  16. CREATE TABLE invoice (
  17. id INT64 NOT NULL,
  18. uuid BYTES(16) NOT NULL,
  19. created TIMESTAMP NOT NULL,
  20. updated TIMESTAMP NOT NULL,
  21. customer INT64 NOT NULL,
  22. invoiceNumber STRING(15) NOT NULL,
  23. description STRING(200) NOT NULL,
  24. amount FLOAT64 NOT NULL,
  25. pdf BYTES(10000000)
  26. )
  27. PRIMARY KEY (id)
  28. ;
  29. -- Execute batch
  30. EXECUTE_DDL_BATCH;
  31. -- Wait for asynchronous ddl operations to finish
  32. WAIT_FOR_DDL_OPERATIONS;
  33.  
  34. -- Create indices in the background (without waiting for them to finish)
  35. CREATE UNIQUE INDEX idx_customer_uuid ON customer (uuid);
  36. CREATE INDEX idx_customer_lastName ON customer (lastName);
  37.  
  38. CREATE UNIQUE INDEX idx_invoice_uuid ON invoice (uuid);
  39. CREATE INDEX idx_invoice_customer on invoice (customer);
  40. CREATE INDEX idx_invoice_invoicenumber_description on invoice (invoiceNumber, description);
  41. -- Execute batch but don't wait
  42. EXECUTE_DDL_BATCH;
  43.  
  44. -- Reset the async and auto batch properties to their defaults
  45. RESET_CONNECTION_PROPERTY AsyncDdlOperations;
  46. RESET_CONNECTION_PROPERTY AutoBatchDdlOperations;
Add Comment
Please, Sign In to add comment