尝试在SQLPLUS命令行中添加外键

时间:2015-10-12 16:52:21

标签: sql oracle

        // initialise table
        var table = $('#example').DataTable( {

            dom:    "<'row'<'col-sm-6' <'toolbar'> > >" +
                    "<'row'<'col-sm-12'tr>>" +
                    "<'row'<'col-sm-5'i><'col-sm-7'p>>",
            processing: true,
            serverSide: true,
            ajax: '{{ route('admin.data') }}',
            columns: [
                {
                    "className":      'center',
                    "orderable":      false,
                    "data":           null,
                    "defaultContent": ''
                },
                { data: 'last_name' },
                { data: 'first_name' },
                { data: 'email' },
                { data: 'phone', orderable: false }
            ],
            order: [[1, 'asc']],
            initComplete: function() {
                $('td.center').html('<i class="fa fa-plus-circle"></i>');
            }

        });

        // add new row
        $('#quick-access .btn-add').on('click', function() {
            var first = $('#val2').val();
            var last = $('#val1').val();
            var email = $('#val3').val();

            table.row.add( [
                'last_name': last,
                'first_name': first,
                'email': email,
                'phone': ''
            } ).draw();
            $("#quick-access").css("bottom","-115px");
        });
  

第3行ORA-00904错误:“SLSREP_NUMBER”:无效标识符

我做错了什么?

1 个答案:

答案 0 :(得分:1)

slsrep_number表中没有名为customer的列。只是做:

CREATE TABLE customer
(
    customer_number VARCHAR(20),
    slsrep_number VARCHAR(20),
    CONSTRAINT pk_customer_number PRIMARY KEY (customer_number),
    CONSTRAINT fk_slsrep_number FOREIGN KEY (slsrep_number) REFERENCES sales_rep(slsrep_number)
);

您可以使用单独的alter table,但您也可以将其放入表格定义中。