SPJ数据库Sql语句

    1. createdatabasespj
    2. go
    3. usespj
    4. go
    5. createtableS
    6. (
    7. Snochar(4)primarykey,
    8. Snamechar(20)unique,
    9. Statussmallint,
    10. Citychar(10)
    11. );
    12. createtableP
    13. (
    14. Pnochar(4)primarykey,
    15. Pnamechar(20),
    16. Colorchar(10),
    17. Weightsmallint,
    18. );
    19. createtableJ
    20. (
    21. Jnochar(4)primarykey,
    22. Jnamechar(20),
    23. Citychar(10)
    24. );
    25. createtableSPJ
    26. (
    27. Snochar(4),
    28. Pnochar(4),
    29. Jnochar(4),
    30. Qtysmallint,
    31. PRIMARYKEY(Sno,Pno,Jno),
    32. FOREIGNKEY(Sno)REFERENCESS(Sno),
    33. FOREIGNKEY(Pno)REFERENCESP(Pno),
    34. FOREIGNKEY(Jno)REFERENCESJ(Jno)
    35. );
    36. insertintoSvalues('S1','精益',20,'天津');
    37. insertintoSvalues('S2','盛锡',10,'北京');
    38. insertintoSvalues('S3','东方红',30,'北京');
    39. insertintoSvalues('S4','丰泰盛',20,'天津');
    40. insertintoSvalues('S5','为民',30,'上海');
    41. insertintoPvalues('P1','螺母','红',12);
    42. insertintoPvalues('P2','螺栓','绿',12);
    43. insertintoPvalues('P3','螺丝刀','蓝',12);
    44. insertintoPvalues('P4','螺丝刀','红',12);
    45. insertintoPvalues('P5','凸轮','蓝',12);
    46. insertintoPvalues('P6','齿轮','红',12);
    47. insertintoJvalues('J1','三建','北京');
    48. insertintoJvalues('J2','一汽','长春');
    49. insertintoJvalues('J3','弹簧厂','天津');
    50. insertintoJvalues('J4','造船厂','天津');
    51. insertintoJvalues('J5','机车厂','唐山');
    52. insertintoJvalues('J6','无线电厂','常州');
    53. insertintoJvalues('J7','半导体厂','南京');
    54. insertintoSPJvalues('S1','P1','J1',200);
    55. insertintoSPJvalues('S1','P1','J3',100);
    56. insertintoSPJvalues('S1','P1','J4',700);
    57. insertintoSPJvalues('S1','P2','J2',100);
    58. insertintoSPJvalues('S2','P3','J1',400);
    59. insertintoSPJvalues('S2','P3','J2',200);
    60. insertintoSPJvalues('S2','P3','J3',500);
    61. insertintoSPJvalues('S2','P3','J4',400);
    62. insertintoSPJvalues('S2','P5','J1',400);
    63. insertintoSPJvalues('S2','P5','J2',100);
    64. insertintoSPJvalues('S3','P1','J1',200);
    65. insertintoSPJvalues('S3','P3','J1',200);
    66. insertintoSPJvalues('S4','P5','J1',100);
    67. insertintoSPJvalues('S4','P6','J3',300);
    68. insertintoSPJvalues('S4','P6','J4',200);
    69. insertintoSPJvalues('S5','P2','J4',100);
    70. insertintoSPJvalues('S5','P3','J1',200);
    71. insertintoSPJvalues('S5','P6','J2',200);
    72. insertintoSPJvalues('S5','P6','J4',500);
    73. select*fromS
    74. select*fromP
    75. select*fromJ
    76. select*fromSPJ

你可能感兴趣的:(sql,Go)