Silahkan masukkan instruksi SQL untuk:
- Mengcreate TABEL Product (DDL)
- Memasukkan Data pada Tabel Product (DML)

Datanya untuk Master Product ditentukan sebagai berikut
Kode Produk, Nama Produk, Jenis Produk, Harga Satuan (per box atau Galon)
1. P0001, Cup 240ml, Cup, 12.000
2. P002, Botol 600ml, Botol, 19.000
3. P003, Botol 1500ml, Botol, 19.500
4. P004, Galon 19L, Galon, 6.000

Blogged with the Flock Browser
VN:F [1.8.1_1037]
Rating: 0.0/10 (0 votes cast)
VN:F [1.8.1_1037]
Rating: 0 (from 0 votes)
Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogosphere News
  • Blogsvine
  • Furl
  • Ma.gnolia
  • Propeller
  • Spurl
  • Technorati
  • Tumblr
  • TwitThis
  • YahooMyWeb
  • StumbleUpon
  • BlinkList
  • LinkedIn
  • Live

Post to Twitter Tweet This Post Post to Delicious Delicious

Tags:

65 Responses to “Piece of Code: Master Product”

  1. Asri Y - 1000845576 - 06PGT says:

    CREATE TABLE MsProduct(
    KdProduk CHAR(5) PRIMARY KEY,
    NmProduk VARCHAR(35) NOT NULL,
    JenisProduk VARCHAR(20) NOT NULL,
    HargaSatuan NUMBER NOT NULL,
    );

    INSERT INTO MsProduct VALUES (’P0001′, ‘Cup 240ml’, ‘Cup’, 12000);
    INSERT INTO MsProduct VALUES (’P002′, ‘Botol 600ml’, ‘Botol’, 19000);
    INSERT INTO MsProduct VALUES (’P003′, ‘Botol 1500ml’, ‘Botol’, 19500);
    INSERT INTO MsProduct VALUES (’P004′, ‘Galon 19L’, ‘Galon’, 6000);

    UN:F [1.8.1_1037]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 0 votes)
  2. Arsy A says:

    NIM : 1000854946
    06PGT

    CREATE TABLE MsProduk(
    KodeProduk VARCHAR2(5)
    CONSTRAINT kdproduk_pk PRIMARY KEY,
    NamaProduk VARCHAR2 (25)
    CONSTRAINT nama_produk_nn NOT NULL,
    JenisProduk VARCHAR2(10)
    CONSTRAINT jenis_produk_nn NOT NULL
    CONSTRAINT jenis_produk_ck
    CHECK (JenisProduk IN (‘Cup’,'Botol’,'Galon’)),
    HargaSatuan NUMBER (10)
    CONSTRAINT harga_nn NOT NULL,
    TglMasuk DATE DEFAULT SYSDATE
    CONSTRAINT tgl_masuk_nn NOT NULL);

    INSERT INTO MsProduk(KodeProduk,NamaProduk,HargaSatuan) VALUES (‘PD001′,’Cup 240ml’,'Cup’,12000);
    INSERT INTO MsProduk(KodeProduk,NamaProduk,HargaSatuan) VALUES (‘PD002′,’Botol 600ml’,'Botol’,19000);
    INSERT INTO MsProduk(KodeProduk,NamaProduk,HargaSatuan) VALUES (‘PD003′,’Botol 1500ml’,'Botol’, 19500);
    INSERT INTO MsProduk(KodeProduk,NamaProduk,HargaSatuan) VALUES (‘PD004′,’Galon 19L’,'Galon’, 6000);

    UN:F [1.8.1_1037]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 0 votes)
  3. Dewi K Chandra says:

    1000860652
    06PGT

    CREATE TABLE MsProduct
    (
    KdProduct CHAR(5) PRIMARY KEY,
    NamaProduct VARCHAR(50) NOT NULL,
    JenisProduct VARCHAR(30) NOT NULL,
    Harga NUMBER NOT NULL
    );

    INSERT INTO MsProduct VALUES(’P001′,’Cup 240ml’,’Cup’,12000);
    INSERT INTO MsProduct VALUES(’P002′,’Botol
    600ml’,’Botol’,19000);
    INSERT INTO MsProduct VALUES(’P003′,’Botol 1500ml’,’Botol’,19500);
    INSERT INTO MsProduct VALUES(’P004′,’Galon 19L’,’Galon’,6000);

    UN:F [1.8.1_1037]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 0 votes)
  4. Beny says:

    Beny
    1000867734
    06PGT

    pak, di soalnya yg KodeProduknya
    1. P0001, Cup 240ml, Cup, 12.000, kelebihan “0″nya yah pak? jadi saya asumsikan KodeProduknya “P001″. makasih pak. :D

    - Mengcreate TABEL Product (DDL)

    CREATE TABLE MsProduct
    (
    KodeProduk char(5) primary key not null,
    NamaProduk varchar(25),
    JenisProduk varchar(15),
    HargaSatuan number(8)
    );

    - Memasukkan Data pada Tabel Product (DML)

    INSERT INTO MsProduk(KodeProduk, NamaProduk, JenisProduk, HargaSatuan) VALUES(’P001′,’Cup 240ml’,’Cup’,12000);
    INSERT INTO MsProduk(KodeProduk, NamaProduk, JenisProduk, HargaSatuan) VALUES(’P002′,’Botol 600ml’,’Botol’,19000);
    INSERT INTO MsProduk(KodeProduk, NamaProduk, JenisProduk, HargaSatuan) VALUES(’P003′,’Botol 1500ml’,’Botol’,19500);
    INSERT INTO MsProduk(KodeProduk, NamaProduk, JenisProduk, HargaSatuan) VALUES(’P004′,’Galon 19L’,’Galon’,6000);

    UN:F [1.8.1_1037]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 0 votes)
  5. Susanti says:

    Susanti
    1000861503
    06PGT

    CREATE TABLE MsProduct
    (
    KodeProduct CHAR(5) PRIMARY KEY,
    NamaProduct VARCHAR(50),
    JenisProduct VARCHAR(50),
    HargaSatuan NUMBER NOT NULL
    );

    INSERT INTO MsProduct VALUES(‘P001′,’Cup 240ml’,'Cup’,12000);
    INSERT INTO MsProduct VALUES(‘P002′,’Botol 600ml’,'Botol’,19000);
    INSERT INTO MsProduct VALUES(‘P003′,’Botol 1500ml’,'Botol’,19500);
    INSERT INTO MsProduct VALUES(‘P004′,’Galon 19L’,'Galon’,6000);

    UN:F [1.8.1_1037]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 0 votes)
  6. 1000835764 says:

    1000835764
    06PGT

    CREATE TABLE MsProduct (
    ProdId VARCHAR2(5) NOT NULL,
    ProdName VARCHAR2(35) NOT NULL,
    ProdType VARCHAR2(25) NOT NULL,
    ProdPrice INT NOT NULL,
    PRIMARY KEY(ProdId)
    );
    INSERT INTO MsProduct VALUES (’P001,’Cup 240 ml’,’Cup’,Rp.12000);
    INSERT INTO MsProduct VALUES (’P002,’Botol 600 ml’,’Botol’,Rp.19000);
    INSERT INTO MsProduct VALUES (’P003,’Botol 1500 ml’,’Botol’,Rp.19500);
    INSERT INTO MsProduct VALUES (’P004,’Galon 19 l’,’Galon’,Rp.6000);

    UN:F [1.8.1_1037]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 0 votes)
  7. Herman 06PGT 1000841842 says:

    Pak kemaren saya uda submit comment pak. Bahkan saya sudah liat di dalam blog Bapak ini tertulis jelas nama Herman. Apakah kehapus Pak ? masa saya bikin ulang lagi? T.T

    UN:F [1.8.1_1037]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 0 votes)
  8. Herman 06PGT 1000841842 says:

    create table Product
    (
    ProductID char(5) primary key not null,
    ProductName varchar(30),
    ProductType varchar(30),
    Price number
    );

    INSERT INTO product VALUES (’P001,’Cup 240ml’,’Cup’,12000);
    INSERT INTO product VALUES (’P002,’Botol 600ml’,’Botol’,19000);
    INSERT INTO product VALUES (’P003,’Botol 1500ml’,’Botol’,19500);
    INSERT INTO product VALUES (’P004,’Galon 19L’,’Galon’,6000);

    UN:F [1.8.1_1037]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 0 votes)
  9. erfan melanaga
    1000873503

    create table Produk
    (
    kdProduk varchar2(50) Primary Key,
    nmProduk varchar2(50),
    jnsProduk varchar2(50),
    hrgSatuan numeric
    );

    insert into produk values(‘P001′,’Cup 240ml’,'Cup’,12000);
    insert into produk values(‘P002′,’Botol 600ml’,'Botol’,19000);
    insert into produk values(‘P003′,’Botol 1000ml’,'Cup’,19500);
    insert into produk values(‘P004′,’Galon 19L’,'Galon’,6000);

    UN:F [1.8.1_1037]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 0 votes)
  10. vania - 06 PBT - 100084271 says:

    CREATE TABLE MasterProduct
    (
    KodeProduk varchar (5) NOT NULL,
    NamaProduk varchar(20),
    JenisProduk varchar (10),
    HargaSatuan INT NOT NULL,
    PRIMARY KEY (KodeProduk)
    );
    INSERT INTO MasterProduct VALUES (‘P0001′, ‘Cup 240ml’, ‘Cup’, 12000);
    INSERT INTO MasterProduct VALUES (‘P002′, ‘Botol 600ml’, ‘Botol’, 19000);
    INSERT INTO MasterProduct VALUES (‘P003′, ‘Botol 1500ml’, ‘Botol’, 19500);
    INSERT INTO MasterProduct VALUES (‘P004′, ‘Galon 19L’, ‘Galon’, 6000);

    UN:F [1.8.1_1037]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 0 votes)
  11. Ora Cell 06PBT says:

    create table Produk
    (
    kdProduk varchar(6),
    namaProduk varchar(15),
    jenisProduk varchar(10),
    hrga numeric (20,2),
    Primary Key(kdProduk)
    );

    insert into produk values(’P001′,’Cup 240ml’,’Cup’,12000);
    insert into produk values(’P002′,’Botol 600ml’,’Botol’,19000);
    insert into produk values(’P003′,’Botol 1000ml’,’Cup’,19500);
    insert into produk values(’P004′,’Galon 19L’,’Galon’,6000);

    UN:F [1.8.1_1037]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 0 votes)
  12. Kelompok SQL 06PBT says:

    CREATE TABLE MsProduct(
    KdProduk VARCHAR(5) PRIMARY KEY,
    NamaProduk VARCHAR(35) NOT NULL,
    JenisProduk VARCHAR(20) NOT NULL,
    Harga NUMBER NOT NULL,
    constraint SI7 check (len(KdProduk) = 5),
    constraint SI8 check (KdProduk like ‘P[0-9][0-9][0-9][0-9]‘)
    );

    INSERT INTO MsProduct VALUES (’P0001′, ‘Cup 240ml’, ‘Cup’, 12000);
    INSERT INTO MsProduct VALUES (’P002′, ‘Botol 600ml’, ‘Botol’, 19000);
    INSERT INTO MsProduct VALUES (’P003′, ‘Botol 1500ml’, ‘Botol’, 19500);
    INSERT INTO MsProduct VALUES (’P004′, ‘Galon 19L’, ‘Galon’, 6000);

    UN:F [1.8.1_1037]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 0 votes)
  13. august 1000843311 06pbt says:

    CREATE TABLE product
    (
    KdProd CHAR(5),
    NmProd VARCHAR2(20),
    JnsProd VARCHAR2(20),
    Hrg NUMBER,
    CONSTRAINT prod_pk PRIMARY KEY(KdProd)
    );

    –menginsert isi tabel produk
    INSERT INTO product VALUES (’P0001′,’Cup 240ml’,’Cup’,12000);
    INSERT INTO product VALUES (’P0002′,’Botol 600ml’,’Botol’,19000);
    INSERT INTO product VALUES (’P0003′,’Botol 1500ml’,’Botol’,19500);
    INSERT INTO product VALUES (’P0004′,’Galon 19L’,’Galon’,6000);

    UN:F [1.8.1_1037]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 0 votes)
  14. Desy Ayu Puspita says:

    DESY AYU P/1000885200/06PGT

    create table Produk (
    KdProduk varchar(8) primary key,
    NamaProduk varchar(20),
    JenisProduk varchar(10),
    Harga varchar(15)
    )

    INSERT INTO Produk (KdProduk,NamaProduk,JenisProduk,Harga) VALUES (P001,’Cup 240ml’,’Cup’,12500)
    INSERT INTO Produk (KdProduk,NamaProduk,JenisProduk,Harga) VALUES (P002,’Botol 600ml’,’Botol’,19500)
    INSERT INTO Produk (KdProduk,NamaProduk,JenisProduk,Harga VALUES (P003,’Botol 1500ml’,’Botol’,20000)
    INSERT INTO Produk (KdProduk,NamaProduk,JenisProduk,Harga) VALUES (P004,’Galon 19l’,’Galon’,6500);

    UN:F [1.8.1_1037]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 0 votes)
  15. Jimmy says:

    Hallo pak, saya mahasiswa binus mau bertanya kalau saya buat web php dengan database mysql, biasanya saya menggunakan fitur auto_increment.
    Yang mau saya tanyakan, bagaimana menggunakan auto_increment dengan check constrain primary key(contoh: S001 saya mau auto_increment yang 001nya saja) terima kasih pak^^

    UN:F [1.8.1_1037]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 0 votes)

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>